Bug 913641 - Execute test steps off the main reload event loop. r=miker

This commit is contained in:
Patrick Brosset 2013-09-11 09:50:44 -04:00
parent 7d44f15b4a
commit a9ed6b7b86
3 changed files with 82 additions and 45 deletions

View File

@ -1,14 +1,21 @@
<!DOCTYPE html>
<div id="id1"></div>
<div id="id2"></div>
<div id="id3">
<ul class="aList">
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
<li class="item">
<span id="id4"></span>
</li>
</ul>
</div>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>select last selected test</title>
</head>
<body>
<div id="id1"></div>
<div id="id2"></div>
<div id="id3">
<ul class="aList">
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
<li class="item">
<span id="id4"></span>
</li>
</ul>
</div>
</body>
</html>

View File

@ -30,23 +30,39 @@ function test() {
}
function endTests() {
toolbox.destroy();
toolbox = inspector = page1 = page2 = null;
gBrowser.removeCurrentTab();
finish();
executeSoon(() => {
toolbox.destroy();
toolbox = inspector = page1 = page2 = null;
gBrowser.removeCurrentTab();
finish();
});
}
function testReSelectingAnElement(id, callback) {
function loadPageAnd(page, callback) {
inspector.once("markuploaded", () => {
executeSoon(callback);
});
if (page) {
content.location = page;
} else {
content.location.reload();
}
}
function reloadAndReselect(id, callback) {
let div = content.document.getElementById(id);
inspector.selection.setNode(div);
inspector.once("inspector-updated", () => {
is(inspector.selection.node, div);
inspector.once("markuploaded", () => {
loadPageAnd(false, () => {
is(inspector.selection.node.id, id, "Node re-selected after reload");
callback();
executeSoon(callback);
});
content.location.reload();
});
inspector.selection.setNode(div);
}
// Test that nodes selected on the test page remain selected after reload
@ -54,10 +70,10 @@ function test() {
{
// Select a few nodes and check they are re-selected after reload of the same
// page
testReSelectingAnElement("id1", () => {
testReSelectingAnElement("id2", () => {
testReSelectingAnElement("id3", () => {
testReSelectingAnElement("id4", testBodySelectedOnNavigate);
reloadAndReselect("id1", () => {
reloadAndReselect("id2", () => {
reloadAndReselect("id3", () => {
reloadAndReselect("id4", testBodySelectedOnNavigate);
});
});
});
@ -68,15 +84,16 @@ function test() {
function testBodySelectedOnNavigate() {
// Last node selected was id4, go to a different page and check body is
// selected
inspector.once("markuploaded", () => {
is(
inspector.selection.node.tagName.toLowerCase(),
"body",
"Node not found, selecting body"
);
testSameNodeSelectedOnNavigateAwayAndBack();
loadPageAnd(page2, () => {
executeSoon(() => {
is(
inspector.selection.node.tagName.toLowerCase(),
"body",
"Node not found, body selected"
);
executeSoon(testSameNodeSelectedOnNavigateAwayAndBack);
});
});
content.location = page2;
}
// Test that the node selected on page 1 gets selected again after a navigation
@ -85,19 +102,25 @@ function test() {
// On page2, select id5
let id = "id5";
let div = content.document.getElementById(id);
inspector.selection.setNode(div);
inspector.once("inspector-updated", () => {
is(inspector.selection.node.id, id);
// go to page1 but do not select anything
inspector.once("markuploaded", () => {
// go back to page2 and check id5 is still the current selection
inspector.once("markuploaded", () => {
is(inspector.selection.node.id, id, "Node re-selected after navigation");
endTests();
executeSoon(() => {
// go to page1 but do not select anything
loadPageAnd(page1, () => {
executeSoon(() => {
// go back to page2 and check id5 is still the current selection
loadPageAnd(page2, () => {
is(inspector.selection.node.id, id, "Node re-selected after navigation");
executeSoon(endTests);
});
});
});
content.location = page2;
});
content.location = page1;
});
inspector.selection.setNode(div);
}
}

View File

@ -1,3 +1,10 @@
<!DOCTYPE html>
<div id="id5"></div>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>select last selected test</title>
</head>
<body>
<div id="id5"></div>
</body>
</html>