Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:firebug/firebug
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Issue 6454: Create FBTest that covers HTML panel search</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
<link href="../../_common/testcase.css" type="text/css" rel="stylesheet"/> | ||
</head> | ||
<body> | ||
<header> | ||
<h1><a href="http://code.google.com/p/fbug/issues/detail?id=6454">Issue 6454</a>: | ||
Create FBTest that covers HTML panel search</h1> | ||
</header> | ||
<div> | ||
<section id="description"> | ||
<h3>Steps to reproduce</h3> | ||
<ol> | ||
<li>Open Firebug, select the HTML panel</li> | ||
<li>Use the search box to search in the panel</li> | ||
<li>There should be 7 occurences of 'testing' (case insensitive)</li> | ||
<li>There should be 2 occurences of 'testing' (case sensitive)</li> | ||
<li>There should be 4 occurences of 'Testing' (case insensitive)</li> | ||
</ol> | ||
</section> | ||
<footer>Jan Odvarko, <odvarko@gmail.com></footer> | ||
</div> | ||
|
||
<div id="test"> | ||
<div>Testing</div> | ||
<span>Testing2</span> | ||
<div style="visibility:collapse;" class="testing"> | ||
<span>Testing</span> | ||
<div class="Testing">testing</span> | ||
<testing>1</testing> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
function runTest() | ||
{ | ||
FBTest.sysout("issue6454.START"); | ||
|
||
FBTest.openNewTab(basePath + "search/6454/issue6454.html", function() | ||
{ | ||
FBTest.openFirebug(); | ||
FBTest.selectPanel("html"); | ||
|
||
var testSuite = []; | ||
|
||
// Test 1: 'testing', forward, case insensitive | ||
testSuite.push(function(callback) | ||
{ | ||
executeSearchTest("testing", false, false, function(counter) | ||
{ | ||
FBTest.compare(7, counter, "There must be precise number " + | ||
"of occurences (7) actual: " + counter); | ||
callback(); | ||
}); | ||
}); | ||
|
||
// Test 2: 'testing', forward, case sensitive | ||
testSuite.push(function(callback) | ||
{ | ||
executeSearchTest("testing", false, true, function(counter) | ||
{ | ||
FBTest.compare(2, counter, "There must be precise number " + | ||
"of occurences (2) actual: " + counter); | ||
callback(); | ||
}); | ||
}); | ||
|
||
// Test 3: 'Testing', forward, case insensitive. | ||
testSuite.push(function(callback) | ||
{ | ||
executeSearchTest("Testing", false, false, function(counter) | ||
{ | ||
FBTest.compare(4, counter, "There must be precise number " + | ||
"of occurences (4) actual: " + counter); | ||
callback(); | ||
}); | ||
}); | ||
|
||
FBTest.runTestSuite(testSuite, function() | ||
{ | ||
FBTest.testDone("issue6454.DONE"); | ||
}); | ||
}); | ||
} | ||
|
||
// xxxHonza: could be shared FBTest API | ||
// Execute one test. | ||
function executeSearchTest(text, reverse, caseSensitive, callback) | ||
{ | ||
var counter = 0; | ||
var firstMatch = null; | ||
|
||
function searchNext() | ||
{ | ||
var panel = FBTest.getPanel("html"); | ||
var sel = panel.document.defaultView.getSelection(); | ||
if (sel.rangeCount != 1) | ||
{ | ||
FBTest.compare(1, sel.rangeCount, "There must be one range selected."); | ||
return callback(counter); | ||
} | ||
|
||
var match = sel.getRangeAt(0); | ||
|
||
// OK, we have found the first occurence again, so finish the test. | ||
FBTest.sysout("search.match; ", match); | ||
if (firstMatch && (firstMatch.compareBoundaryPoints(Range.START_TO_START, match) || | ||
firstMatch.compareBoundaryPoints(Range.END_TO_END, match)) == 0) | ||
return callback(counter); | ||
|
||
// Remember the first match. | ||
if (!firstMatch) | ||
{ | ||
firstMatch = match; | ||
FBTest.sysout("search.firstMatch; ", firstMatch); | ||
} | ||
|
||
counter++; | ||
|
||
doSearch(text, reverse, caseSensitive, callback); | ||
setTimeout(searchNext, 300); | ||
}; | ||
|
||
doSearch(text, reverse, caseSensitive, callback); | ||
setTimeout(searchNext, 300); | ||
} | ||
|
||
// Set search box value and global search options. | ||
function doSearch(text, reverse, caseSensitive, callback) | ||
{ | ||
FW.Firebug.chrome.$("fbSearchBox").value = text; | ||
FBTest.setPref("searchCaseSensitive", caseSensitive); | ||
|
||
// Press enter key within the search box. | ||
FBTest.focus(FW.Firebug.chrome.$("fbSearchBox")); | ||
FBTest.sendKey("RETURN", "fbSearchBox"); | ||
} |