toolkit/devtools/server/tests/mochitest/test_inspector-mutations-frameload.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug </title>
michael@0 9
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
michael@0 12 <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
michael@0 13 <script type="application/javascript;version=1.8">
michael@0 14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
michael@0 15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {});
michael@0 16
michael@0 17 const inspector = devtools.require("devtools/server/actors/inspector");
michael@0 18
michael@0 19 window.onload = function() {
michael@0 20 SimpleTest.waitForExplicitFinish();
michael@0 21 runNextTest();
michael@0 22 }
michael@0 23
michael@0 24 var gInspectee = null;
michael@0 25 var gWalker = null;
michael@0 26 var gClient = null;
michael@0 27 var gChildFrame = null;
michael@0 28 var gChildDocument = null;
michael@0 29 var gCleanupConnection = null;
michael@0 30
michael@0 31 function setup(callback) {
michael@0 32 let url = document.getElementById("inspectorContent").href;
michael@0 33 gCleanupConnection = attachURL(url, function(err, client, tab, doc) {
michael@0 34 gInspectee = doc;
michael@0 35 let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
michael@0 36 let inspector = InspectorFront(client, tab);
michael@0 37 promiseDone(inspector.getWalker().then(walker => {
michael@0 38 gClient = client;
michael@0 39 gWalker = walker;
michael@0 40 }).then(callback));
michael@0 41 });
michael@0 42 }
michael@0 43
michael@0 44 function teardown() {
michael@0 45 gWalker = null;
michael@0 46 gClient = null;
michael@0 47 gInspectee = null;
michael@0 48 gChildFrame = null;
michael@0 49 if (gCleanupConnection) {
michael@0 50 gCleanupConnection();
michael@0 51 gCleanupConnection = null;
michael@0 52 }
michael@0 53 }
michael@0 54
michael@0 55 function assertOwnership() {
michael@0 56 return assertOwnershipTrees(gWalker);
michael@0 57 }
michael@0 58
michael@0 59 function loadChildSelector(selector) {
michael@0 60 return gWalker.querySelector(gWalker.rootNode, "#childFrame").then(frame => {
michael@0 61 ok(frame.numChildren > 0, "Child frame should consider its loaded document as a child.");
michael@0 62 gChildFrame = frame;
michael@0 63 return gWalker.children(frame);
michael@0 64 }).then(children => {
michael@0 65 return gWalker.querySelectorAll(children.nodes[0], selector);
michael@0 66 }).then(nodeList => {
michael@0 67 return nodeList.items();
michael@0 68 });
michael@0 69 }
michael@0 70
michael@0 71 function getUnloadedDoc(mutations) {
michael@0 72 for (let change of mutations) {
michael@0 73 if (isUnload(change)) {
michael@0 74 return change.target;
michael@0 75 }
michael@0 76 }
michael@0 77 return null;
michael@0 78 }
michael@0 79
michael@0 80 addTest(function loadNewChild() {
michael@0 81 setup(() => {
michael@0 82 let beforeUnloadSize = 0;
michael@0 83 // Load a bunch of fronts for actors inside the child frame.
michael@0 84 promiseDone(loadChildSelector("#longlist div").then(() => {
michael@0 85 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 86 childFrame.src = "data:text/html,<html>new child</html>";
michael@0 87 return waitForMutation(gWalker, isChildList);
michael@0 88 }).then(mutations => {
michael@0 89 let unloaded = getUnloadedDoc(mutations);
michael@0 90 mutations = assertSrcChange(mutations);
michael@0 91 mutations = assertUnload(mutations);
michael@0 92 mutations = assertFrameLoad(mutations);
michael@0 93 mutations = assertChildList(mutations);
michael@0 94
michael@0 95 is(mutations.length, 0, "Got the expected mutations.");
michael@0 96
michael@0 97 assertOwnership();
michael@0 98
michael@0 99 return checkMissing(gClient, unloaded);
michael@0 100 }).then(() => {
michael@0 101 teardown();
michael@0 102 }).then(runNextTest));
michael@0 103 });
michael@0 104 });
michael@0 105
michael@0 106 addTest(function loadNewChildTwice() {
michael@0 107 setup(() => {
michael@0 108 let beforeUnloadSize = 0;
michael@0 109 // Load a bunch of fronts for actors inside the child frame.
michael@0 110 promiseDone(loadChildSelector("#longlist div").then(() => {
michael@0 111 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 112 childFrame.src = "data:text/html,<html>new child</html>";
michael@0 113 return waitForMutation(gWalker, isChildList);
michael@0 114 }).then(mutations => {
michael@0 115 // The first load went through as expected (as tested in loadNewChild)
michael@0 116 // Now change the source again, but this time we *don't* expect
michael@0 117 // an unload, because we haven't seen the new child document yet.
michael@0 118 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 119 childFrame.src = "data:text/html,<html>second new child</html>";
michael@0 120 return waitForMutation(gWalker, isChildList);
michael@0 121 }).then(mutations => {
michael@0 122 mutations = assertSrcChange(mutations);
michael@0 123 mutations = assertFrameLoad(mutations);
michael@0 124 mutations = assertChildList(mutations);
michael@0 125 ok(!getUnloadedDoc(mutations), "Should not have gotten an unload.");
michael@0 126
michael@0 127 is(mutations.length, 0, "Got the expected mutations.");
michael@0 128
michael@0 129 assertOwnership();
michael@0 130 }).then(() => {
michael@0 131 teardown();
michael@0 132 }).then(runNextTest));
michael@0 133 });
michael@0 134 });
michael@0 135
michael@0 136
michael@0 137 addTest(function loadNewChildTwiceAndCareAboutIt() {
michael@0 138 setup(() => {
michael@0 139 let beforeUnloadSize = 0;
michael@0 140 // Load a bunch of fronts for actors inside the child frame.
michael@0 141 promiseDone(loadChildSelector("#longlist div").then(() => {
michael@0 142 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 143 childFrame.src = "data:text/html,<html>new child</html>";
michael@0 144 return waitForMutation(gWalker, isChildList);
michael@0 145 }).then(mutations => {
michael@0 146 // Read the new child
michael@0 147 return loadChildSelector("#longlist div");
michael@0 148 }).then(() => {
michael@0 149 // Now change the source again, and expect the same results as loadNewChild.
michael@0 150 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 151 childFrame.src = "data:text/html,<html>second new child</html>";
michael@0 152 return waitForMutation(gWalker, isChildList);
michael@0 153 }).then(mutations => {
michael@0 154 let unloaded = getUnloadedDoc(mutations);
michael@0 155
michael@0 156 mutations = assertSrcChange(mutations);
michael@0 157 mutations = assertUnload(mutations);
michael@0 158 mutations = assertFrameLoad(mutations);
michael@0 159 mutations = assertChildList(mutations);
michael@0 160
michael@0 161 is(mutations.length, 0, "Got the expected mutations.");
michael@0 162
michael@0 163 assertOwnership();
michael@0 164
michael@0 165 return checkMissing(gClient, unloaded);
michael@0 166 }).then(() => {
michael@0 167 teardown();
michael@0 168 }).then(runNextTest));
michael@0 169 });
michael@0 170 });
michael@0 171
michael@0 172 addTest(function testBack() {
michael@0 173 setup(() => {
michael@0 174 let beforeUnloadSize = 0;
michael@0 175 // Load a bunch of fronts for actors inside the child frame.
michael@0 176 promiseDone(loadChildSelector("#longlist div").then(() => {
michael@0 177 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 178 childFrame.src = "data:text/html,<html>new child</html>";
michael@0 179 return waitForMutation(gWalker, isChildList);
michael@0 180 }).then(mutations => {
michael@0 181 // Read the new child
michael@0 182 return loadChildSelector("#longlist div");
michael@0 183 }).then(() => {
michael@0 184 // Now use history.back to change the source, and expect the same results as loadNewChild.
michael@0 185 let childFrame = gInspectee.querySelector("#childFrame");
michael@0 186 childFrame.contentWindow.history.back();
michael@0 187 return waitForMutation(gWalker, isChildList);
michael@0 188 }).then(mutations => {
michael@0 189 let unloaded = getUnloadedDoc(mutations);
michael@0 190 mutations = assertSrcChange(mutations);
michael@0 191 mutations = assertUnload(mutations);
michael@0 192 mutations = assertFrameLoad(mutations);
michael@0 193 mutations = assertChildList(mutations);
michael@0 194 is(mutations.length, 0, "Got the expected mutations.");
michael@0 195
michael@0 196 assertOwnership();
michael@0 197
michael@0 198 return checkMissing(gClient, unloaded);
michael@0 199 }).then(() => {
michael@0 200 teardown();
michael@0 201 }).then(runNextTest));
michael@0 202 });
michael@0 203 });
michael@0 204
michael@0 205 </script>
michael@0 206 </head>
michael@0 207 <body>
michael@0 208 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
michael@0 209 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
michael@0 210 <p id="display"></p>
michael@0 211 <div id="content" style="display: none">
michael@0 212
michael@0 213 </div>
michael@0 214 <pre id="test">
michael@0 215 </pre>
michael@0 216 </body>
michael@0 217 </html>

mercurial