Bug 864845 part 1. Stop using 'content' in devtools tests. r=ochameau

MozReview-Commit-ID: 5PppAzRx5JG
This commit is contained in:
Boris Zbarsky 2017-09-12 15:33:10 -04:00
parent cc009d1289
commit 8419a57f7a
18 changed files with 60 additions and 60 deletions

View File

@ -18,14 +18,14 @@ add_task(function* () {
info("Navigate to the second page");
let onMarkupLoaded = waitForMarkupLoaded(inspector);
yield testActor.eval(`content.location.href="${IFRAME2}"`);
yield testActor.eval(`location.href="${IFRAME2}"`);
yield onMarkupLoaded;
yield testSecondPage(inspector, view, testActor);
info("Go back to the first page");
onMarkupLoaded = waitForMarkupLoaded(inspector);
yield testActor.eval("content.history.back();");
yield testActor.eval("history.back();");
yield onMarkupLoaded;
yield testBackToFirstPage(inspector, view, testActor);

View File

@ -103,15 +103,15 @@ function waitForMarkupLoaded(inspector) {
function getStyle(testActor, selector, propertyName) {
return testActor.eval(`
content.document.querySelector("${selector}")
.style.getPropertyValue("${propertyName}");
document.querySelector("${selector}")
.style.getPropertyValue("${propertyName}");
`);
}
function setStyle(testActor, selector, propertyName, value) {
return testActor.eval(`
content.document.querySelector("${selector}")
.style.${propertyName} = "${value}";
document.querySelector("${selector}")
.style.${propertyName} = "${value}";
`);
}

View File

@ -53,7 +53,7 @@ add_task(function* () {
state.grids[0].highlighted &&
!state.grids[1].highlighted);
testActor.eval(`
content.document.getElementById("grid2").classList.add("grid");
document.getElementById("grid2").classList.add("grid");
`);
yield onGridListUpdate;

View File

@ -51,7 +51,7 @@ add_task(function* () {
let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
onCheckboxChange = waitUntilState(store, state => state.grids.length == 0);
testActor.eval(`
content.document.getElementById("grid").remove();
document.getElementById("grid").remove();
`);
yield onHighlighterHidden;
yield onCheckboxChange;

View File

@ -57,9 +57,9 @@ add_task(function* () {
let onGridOutlineChanged = waitForDOM(doc, ".grid-outline-cell", 4);
testActor.eval(`
const div = content.document.createElement("div");
const div = document.createElement("div");
div.textContent = "item 3";
content.document.querySelector(".container").appendChild(div);
document.querySelector(".container").appendChild(div);
`);
yield onReflow;

View File

@ -22,7 +22,7 @@ add_task(function* () {
yield selectNode("canvas", inspector);
yield assertCopyImageDataAvailable(inspector);
let expectedURL = yield testActor.eval(`
content.document.querySelector(".canvas").toDataURL();`);
document.querySelector(".canvas").toDataURL();`);
yield triggerCopyImageUrlAndWaitForClipboard(expectedURL, inspector);
// Check again that the menu isn't available on the DIV (to make sure our

View File

@ -18,10 +18,10 @@ const TEST_DATA = [
is(pageNodeFront, selectedNodeFront, "Original element is selected");
let textNodeName = yield testActor.eval(`
content.document.querySelector("#badMarkup1").nextSibling.nodeName
document.querySelector("#badMarkup1").nextSibling.nodeName
`);
let textNodeData = yield testActor.eval(`
content.document.querySelector("#badMarkup1").nextSibling.data
document.querySelector("#badMarkup1").nextSibling.data
`);
is(textNodeName, "#text", "Sibling is a text element");
is(textNodeData, " hanging", "New text node has expected text content");
@ -36,10 +36,10 @@ const TEST_DATA = [
is(pageNodeFront, selectedNodeFront, "Original element is selected");
let textNodeName = yield testActor.eval(`
content.document.querySelector("#badMarkup2").nextSibling.nodeName
document.querySelector("#badMarkup2").nextSibling.nodeName
`);
let textNodeData = yield testActor.eval(`
content.document.querySelector("#badMarkup2").nextSibling.data
document.querySelector("#badMarkup2").nextSibling.data
`);
is(textNodeName, "#text", "Sibling is a text element");
is(textNodeData, " hanging", "New text node has expected text content");

View File

@ -121,9 +121,9 @@ function* testHead(inspector, testActor) {
yield onReselected;
yield onUpdated;
is((yield testActor.eval("content.document.title")), "New Title",
is((yield testActor.eval("document.title")), "New Title",
"New title has been added");
is((yield testActor.eval("content.foo")), undefined,
is((yield testActor.eval("window.foo")), undefined,
"Script has not been executed");
is((yield testActor.getProperty("head", "outerHTML")), headHTML,
"<head> HTML has been updated");
@ -133,7 +133,7 @@ function* testHead(inspector, testActor) {
function* testDocumentElement(inspector, testActor) {
let currentDocElementOuterHMTL = yield testActor.eval(
"content.document.documentElement.outerHMTL");
"document.documentElement.outerHMTL");
let docElementHTML = "<html id=\"updated\" foo=\"bar\"><head>" +
"<title>Updated from document element</title>" +
"<script>window.foo=\"bar\";</script></head><body>" +
@ -145,9 +145,9 @@ function* testDocumentElement(inspector, testActor) {
currentDocElementOuterHMTL);
yield onReselected;
is((yield testActor.eval("content.document.title")),
is((yield testActor.eval("document.title")),
"Updated from document element", "New title has been added");
is((yield testActor.eval("content.foo")),
is((yield testActor.eval("window.foo")),
undefined, "Script has not been executed");
is((yield testActor.getAttribute("html", "id")),
"updated", "<html> ID has been updated");
@ -167,7 +167,7 @@ function* testDocumentElement(inspector, testActor) {
function* testDocumentElement2(inspector, testActor) {
let currentDocElementOuterHMTL = yield testActor.eval(
"content.document.documentElement.outerHMTL");
"document.documentElement.outerHMTL");
let docElementHTML = "<html id=\"somethingelse\" class=\"updated\"><head>" +
"<title>Updated again from document element</title>" +
"<script>window.foo=\"bar\";</script></head><body>" +
@ -179,9 +179,9 @@ function* testDocumentElement2(inspector, testActor) {
currentDocElementOuterHMTL);
yield onReselected;
is((yield testActor.eval("content.document.title")),
is((yield testActor.eval("document.title")),
"Updated again from document element", "New title has been added");
is((yield testActor.eval("content.foo")),
is((yield testActor.eval("window.foo")),
undefined, "Script has not been executed");
is((yield testActor.getAttribute("html", "id")),
"somethingelse", "<html> ID has been updated");

View File

@ -76,10 +76,10 @@ add_task(function* () {
*/
function* checkElementIsInViewport(selector, expected, testActor) {
let isInViewport = yield testActor.eval(`
let node = content.document.querySelector("${selector}");
let node = document.querySelector("${selector}");
let rect = node.getBoundingClientRect();
rect.bottom >= 0 && rect.right >= 0 &&
rect.top <= content.innerHeight && rect.left <= content.innerWidth;
rect.top <= window.innerHeight && rect.left <= window.innerWidth;
`);
is(isInViewport, expected,

View File

@ -104,7 +104,7 @@ const TEST_DATA = [
numMutations: 2,
test: function* (testActor) {
yield testActor.eval(`
let node1 = content.document.querySelector("#node1");
let node1 = document.querySelector("#node1");
node1.classList.add("pseudo");
`);
},
@ -119,7 +119,7 @@ const TEST_DATA = [
numMutations: 2,
test: function* (testActor) {
yield testActor.eval(`
let node1 = content.document.querySelector("#node1");
let node1 = document.querySelector("#node1");
node1.classList.remove("pseudo");
`);
},
@ -146,7 +146,7 @@ const TEST_DATA = [
desc: "Adding a second text child",
test: function* (testActor) {
yield testActor.eval(`
let node1 = content.document.querySelector("#node1");
let node1 = document.querySelector("#node1");
let newText = node1.ownerDocument.createTextNode("more");
node1.appendChild(newText);
`);
@ -223,7 +223,7 @@ const TEST_DATA = [
desc: "Removing child nodes",
test: function* (testActor) {
yield testActor.eval(`
let node4 = content.document.querySelector("#node4");
let node4 = document.querySelector("#node4");
while (node4.firstChild) {
node4.removeChild(node4.firstChild);
}
@ -238,8 +238,8 @@ const TEST_DATA = [
desc: "Appending a child to a different parent",
test: function* (testActor) {
yield testActor.eval(`
let node17 = content.document.querySelector("#node17");
let node2 = content.document.querySelector("#node2");
let node17 = document.querySelector("#node17");
let node2 = document.querySelector("#node2");
node2.appendChild(node17);
`);
},
@ -271,9 +271,9 @@ const TEST_DATA = [
// node19
test: function* (testActor) {
yield testActor.eval(`
let node18 = content.document.querySelector("#node18");
let node20 = content.document.querySelector("#node20");
let node1 = content.document.querySelector("#node1");
let node18 = document.querySelector("#node18");
let node20 = document.querySelector("#node20");
let node1 = document.querySelector("#node1");
node1.appendChild(node20);
node20.appendChild(node18);
`);

View File

@ -25,9 +25,9 @@ const TEST_DATA = [{
desc: "Adding a new node should flash the new node",
mutate: function* (testActor) {
yield testActor.eval(`
let newLi = content.document.createElement("LI");
let newLi = document.createElement("LI");
newLi.textContent = "new list item";
content.document.querySelector(".list").appendChild(newLi);
document.querySelector(".list").appendChild(newLi);
`);
},
flashedNode: ".list li:nth-child(3)"
@ -35,7 +35,7 @@ const TEST_DATA = [{
desc: "Removing a node should flash its parent",
mutate: function* (testActor) {
yield testActor.eval(`
let root = content.document.querySelector(".list");
let root = document.querySelector(".list");
root.removeChild(root.lastElementChild);
`);
}
@ -43,7 +43,7 @@ const TEST_DATA = [{
desc: "Re-appending an existing node should only flash this node",
mutate: function* (testActor) {
yield testActor.eval(`
let root = content.document.querySelector(".list");
let root = document.querySelector(".list");
root.appendChild(root.firstElementChild);
`);
},
@ -72,7 +72,7 @@ const TEST_DATA = [{
attribute: "class",
mutate: function* (testActor) {
yield testActor.eval(`
let root = content.document.querySelector(".list");
let root = document.querySelector(".list");
root.removeAttribute("class");
root.setAttribute("class", "list value-" + Date.now());
root.setAttribute("class", "list value-" + Date.now());
@ -85,7 +85,7 @@ const TEST_DATA = [{
desc: "Removing an attribute should flash the node",
mutate: function* (testActor) {
yield testActor.eval(`
let root = content.document.querySelector(".list");
let root = document.querySelector(".list");
root.removeAttribute("class");
`);
}

View File

@ -15,10 +15,10 @@ const TEST_DATA = [
before: true,
changeStyle: function* (testActor) {
yield testActor.eval(`
let div = content.document.createElement("div");
let div = document.createElement("div");
div.id = "new-style";
div.innerHTML = "<style>#normal-div {display:none;}</style>";
content.document.body.appendChild(div);
document.body.appendChild(div);
`);
},
after: false
@ -29,7 +29,7 @@ const TEST_DATA = [
before: false,
changeStyle: function* (testActor) {
yield testActor.eval(`
content.document.getElementById("new-style").remove();
document.getElementById("new-style").remove();
`);
},
after: true
@ -40,7 +40,7 @@ const TEST_DATA = [
before: false,
changeStyle: function* (testActor) {
yield testActor.eval(`
let node = content.document.querySelector("#display-none");
let node = document.querySelector("#display-none");
node.style.display = "block";
`);
},
@ -52,8 +52,8 @@ const TEST_DATA = [
before: false,
changeStyle: function* (testActor) {
yield testActor.eval(`
content.document.querySelector("#hidden-true")
.removeAttribute("hidden");
document.querySelector("#hidden-true")
.removeAttribute("hidden");
`);
},
after: true
@ -73,9 +73,9 @@ const TEST_DATA = [
before: false,
changeStyle: function* (testActor) {
yield testActor.eval(`
content.document.styleSheets[0]
.cssRules[0].style
.setProperty("display", "inline");
document.styleSheets[0]
.cssRules[0].style
.setProperty("display", "inline");
`);
},
after: true
@ -86,7 +86,7 @@ const TEST_DATA = [
before: true,
changeStyle: function* (testActor) {
yield testActor.eval(`
content.document.styleSheets[0].insertRule(
document.styleSheets[0].insertRule(
"#hidden-via-stylesheet {display: none;}", 1);
`);
},
@ -98,10 +98,10 @@ const TEST_DATA = [
before: true,
changeStyle: function* (testActor) {
yield testActor.eval(`
content.document.styleSheets[0].insertRule(
document.styleSheets[0].insertRule(
".a-new-class {display: none;}", 2);
content.document.querySelector("#normal-div")
.classList.add("a-new-class");
document.querySelector("#normal-div")
.classList.add("a-new-class");
`);
},
after: false

View File

@ -15,7 +15,7 @@ add_task(function* () {
yield selectNode("#one", inspector);
let willNavigate = inspector.target.once("will-navigate");
yield testActor.eval(`content.location = "${URL_2}"`);
yield testActor.eval(`window.location = "${URL_2}"`);
info("Waiting for will-navigate");
yield willNavigate;

View File

@ -112,7 +112,7 @@ Task.async(function* (selector, inspector, expectFailure = false) {
*/
function* getFirstChildNodeValue(selector, testActor) {
let nodeValue = yield testActor.eval(`
content.document.querySelector("${selector}").firstChild.nodeValue;
document.querySelector("${selector}").firstChild.nodeValue;
`);
return nodeValue;
}

View File

@ -37,7 +37,7 @@ add_task(function* () {
let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
info("Remove the #grid container in the content page");
testActor.eval(`
content.document.querySelector("#grid").remove();
document.querySelector("#grid").remove();
`);
yield onHighlighterHidden;
ok(!highlighters.gridHighlighterShown, "CSS grid highlighter is hidden.");

View File

@ -36,7 +36,7 @@ add_task(function* () {
let onHighlighterHidden = highlighters.once("shapes-highlighter-hidden");
info("Remove the #shapes container in the content page");
testActor.eval(`
content.document.querySelector("#shape").remove();
document.querySelector("#shape").remove();
`);
yield onHighlighterHidden;
ok(!highlighters.shapesHighlighterShown, "CSS shapes highlighter is hidden.");

View File

@ -57,8 +57,8 @@ addTab = function (url) {
*/
function getStyle(testActor, selector, propName) {
return testActor.eval(`
content.document.querySelector("${selector}")
.style.getPropertyValue("${propName}");
document.querySelector("${selector}")
.style.getPropertyValue("${propName}");
`);
}

View File

@ -84,7 +84,7 @@ add_task(function* () {
executeSoon(resolve);
});
ok((yield testActor.eval("!!content.document.documentElement")),
ok((yield testActor.eval("!!document.documentElement")),
"Document element still alive.");
}