summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/server/tests/mochitest/test_inspector-mutations-frameload.html')
-rw-r--r--devtools/server/tests/mochitest/test_inspector-mutations-frameload.html214
1 files changed, 214 insertions, 0 deletions
diff --git a/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html b/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
new file mode 100644
index 000000000..54966cea7
--- /dev/null
+++ b/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html
@@ -0,0 +1,214 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug </title>
+
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
+ <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
+ <script type="application/javascript;version=1.8">
+const inspector = require("devtools/shared/fronts/inspector");
+
+window.onload = function() {
+ SimpleTest.waitForExplicitFinish();
+ runNextTest();
+}
+
+var gInspectee = null;
+var gWalker = null;
+var gClient = null;
+var gChildFrame = null;
+var gChildDocument = null;
+var gCleanupConnection = null;
+
+function setup(callback) {
+ let url = document.getElementById("inspectorContent").href;
+ gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
+ gInspectee = doc;
+ let {InspectorFront} = require("devtools/shared/fronts/inspector");
+ let inspector = InspectorFront(client, tab);
+ promiseDone(inspector.getWalker().then(walker => {
+ gClient = client;
+ gWalker = walker;
+ }).then(callback));
+ });
+}
+
+function teardown() {
+ gWalker = null;
+ gClient = null;
+ gInspectee = null;
+ gChildFrame = null;
+ if (gCleanupConnection) {
+ gCleanupConnection();
+ gCleanupConnection = null;
+ }
+}
+
+function assertOwnership() {
+ return assertOwnershipTrees(gWalker);
+}
+
+function loadChildSelector(selector) {
+ return gWalker.querySelector(gWalker.rootNode, "#childFrame").then(frame => {
+ ok(frame.numChildren > 0, "Child frame should consider its loaded document as a child.");
+ gChildFrame = frame;
+ return gWalker.children(frame);
+ }).then(children => {
+ return gWalker.querySelectorAll(children.nodes[0], selector);
+ }).then(nodeList => {
+ return nodeList.items();
+ });
+}
+
+function getUnloadedDoc(mutations) {
+ for (let change of mutations) {
+ if (isUnload(change)) {
+ return change.target;
+ }
+ }
+ return null;
+}
+
+addTest(function loadNewChild() {
+ setup(() => {
+ let beforeUnloadSize = 0;
+ // Load a bunch of fronts for actors inside the child frame.
+ promiseDone(loadChildSelector("#longlist div").then(() => {
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ let unloaded = getUnloadedDoc(mutations);
+ mutations = assertSrcChange(mutations);
+ mutations = assertUnload(mutations);
+ mutations = assertFrameLoad(mutations);
+ mutations = assertChildList(mutations);
+
+ is(mutations.length, 0, "Got the expected mutations.");
+
+ assertOwnership();
+
+ return checkMissing(gClient, unloaded);
+ }).then(() => {
+ teardown();
+ }).then(runNextTest));
+ });
+});
+
+addTest(function loadNewChildTwice() {
+ setup(() => {
+ let beforeUnloadSize = 0;
+ // Load a bunch of fronts for actors inside the child frame.
+ promiseDone(loadChildSelector("#longlist div").then(() => {
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ // The first load went through as expected (as tested in loadNewChild)
+ // Now change the source again, but this time we *don't* expect
+ // an unload, because we haven't seen the new child document yet.
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>second new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ mutations = assertSrcChange(mutations);
+ mutations = assertFrameLoad(mutations);
+ mutations = assertChildList(mutations);
+ ok(!getUnloadedDoc(mutations), "Should not have gotten an unload.");
+
+ is(mutations.length, 0, "Got the expected mutations.");
+
+ assertOwnership();
+ }).then(() => {
+ teardown();
+ }).then(runNextTest));
+ });
+});
+
+
+addTest(function loadNewChildTwiceAndCareAboutIt() {
+ setup(() => {
+ let beforeUnloadSize = 0;
+ // Load a bunch of fronts for actors inside the child frame.
+ promiseDone(loadChildSelector("#longlist div").then(() => {
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ // Read the new child
+ return loadChildSelector("#longlist div");
+ }).then(() => {
+ // Now change the source again, and expect the same results as loadNewChild.
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>second new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ let unloaded = getUnloadedDoc(mutations);
+
+ mutations = assertSrcChange(mutations);
+ mutations = assertUnload(mutations);
+ mutations = assertFrameLoad(mutations);
+ mutations = assertChildList(mutations);
+
+ is(mutations.length, 0, "Got the expected mutations.");
+
+ assertOwnership();
+
+ return checkMissing(gClient, unloaded);
+ }).then(() => {
+ teardown();
+ }).then(runNextTest));
+ });
+});
+
+addTest(function testBack() {
+ setup(() => {
+ let beforeUnloadSize = 0;
+ // Load a bunch of fronts for actors inside the child frame.
+ promiseDone(loadChildSelector("#longlist div").then(() => {
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.src = "data:text/html,<html>new child</html>";
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ // Read the new child
+ return loadChildSelector("#longlist div");
+ }).then(() => {
+ // Now use history.back to change the source, and expect the same results as loadNewChild.
+ let childFrame = gInspectee.querySelector("#childFrame");
+ childFrame.contentWindow.history.back();
+ return waitForMutation(gWalker, isChildList);
+ }).then(mutations => {
+ let unloaded = getUnloadedDoc(mutations);
+ mutations = assertSrcChange(mutations);
+ mutations = assertUnload(mutations);
+ mutations = assertFrameLoad(mutations);
+ mutations = assertChildList(mutations);
+ is(mutations.length, 0, "Got the expected mutations.");
+
+ assertOwnership();
+
+ return checkMissing(gClient, unloaded);
+ }).then(() => {
+ teardown();
+ }).then(runNextTest));
+ });
+});
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
+<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>