Skip to content

Commit

Permalink
Merge branch 'master' of github.com:firebug/firebug
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed May 20, 2013
2 parents 271c385 + 0799b92 commit 1f600fd
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/content/firebug.html
Expand Up @@ -70,6 +70,7 @@
{group: "search", uri: "search/4602/issue4602.js", desc: "Transfer text selection to Search Field when it's focussed using the keyboard shortcut", testPage: "search/4602/issue4602.html" },
{group: "search", uri: "search/4603/issue4603.js", desc: "Add clear button to the Search Field", testPage: "search/4603/issue4603.html" },
{group: "search", uri: "search/6435/issue6435.js", desc: "Create FBTest that covers DOM panel search", testPage: "search/6435/issue6435.html" },
{group: "search", uri: "search/6454/issue6454.js", desc: "Create FBTest that covers HTML panel search", testPage: "search/6454/issue6454.html" },
{group: "shortcuts", uri: "shortcuts/firebug.js", desc: "Firebug shortcuts (F12, Shift+F12, Ctrl+F12)", testPage: "shortcuts/firebug.html" },
{group: "shortcuts", uri: "shortcuts/inspector.js", desc: "Inspector shortcut (Ctrl+Shift+C)", testPage: "shortcuts/inspector.html" },
{group: "examples", uri: "examples/exampleCommandLine1.js", desc: "Example test showing how to test the command line.", testPage: "examples/exampleCommandLine1.html" },
Expand Down
38 changes: 38 additions & 0 deletions tests/content/search/6454/issue6454.html
@@ -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, &lt;odvarko@gmail.com&gt;</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>
103 changes: 103 additions & 0 deletions tests/content/search/6454/issue6454.js
@@ -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");
}

0 comments on commit 1f600fd

Please sign in to comment.