Sat, 03 Jan 2015 20:18:00 +0100
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.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug </title>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
12 <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
13 <script type="application/javascript;version=1.8">
14 Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
15 const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {});
17 const inspector = devtools.require("devtools/server/actors/inspector");
19 window.onload = function() {
20 SimpleTest.waitForExplicitFinish();
21 runNextTest();
22 }
24 const testSummaryLength = 10;
25 inspector.setValueSummaryLength(testSummaryLength);
26 SimpleTest.registerCleanupFunction(function() {
27 inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH);
28 });
30 var gInspectee = null;
31 var gWalker = null;
32 var gClient = null;
33 var valueNode;
34 var valueFront;
35 var longString = "stringstringstringstringstringstringstringstringstringstringstring";
36 var truncatedLongString = longString.substring(0, testSummaryLength);
37 var shortString = "str";
38 var shortString2 = "str2";
40 addTest(function setup() {
41 let url = document.getElementById("inspectorContent").href;
42 attachURL(url, function(err, client, tab, doc) {
43 gInspectee = doc;
44 let {InspectorFront} = devtools.require("devtools/server/actors/inspector");
45 let inspector = InspectorFront(client, tab);
46 promiseDone(inspector.getWalker().then(walker => {
47 ok(walker, "getWalker() should return an actor.");
48 gClient = client;
49 gWalker = walker;
50 }).then(runNextTest));
51 });
52 });
54 addTest(setupValueTest);
55 addTest(testKeepLongValue);
56 addTest(testSetShortValue);
57 addTest(testKeepShortValue);
58 addTest(testSetLongValue);
59 addTest(setupFrameValueTest);
60 addTest(testKeepLongValue);
61 addTest(testSetShortValue);
62 addTest(testKeepShortValue);
63 addTest(testSetLongValue);
65 function setupValueTest() {
66 valueNode = gInspectee.querySelector("#longstring").firstChild;
67 promiseDone(gWalker.querySelector(gWalker.rootNode, "#longstring").then(node => {
68 return gWalker.children(node);
69 }).then(children => {
70 valueFront = children.nodes[0];
71 }).then(runNextTest));
72 }
74 function setupFrameValueTest() {
75 let frame = gInspectee.querySelector('#childFrame');
76 valueNode = frame.contentDocument.querySelector("#longstring").firstChild;
78 promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
79 return gWalker.children(childFrame);
80 }).then(children => {
81 let nodes = children.nodes;
82 ok(nodes.length, 1, "There should be only one child of the iframe");
83 is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
84 return gWalker.querySelector(nodes[0], "#longstring");
85 }).then(node => {
86 return gWalker.children(node);
87 }).then(children => {
88 valueFront = children.nodes[0];
89 }).then(runNextTest));
90 }
92 function testKeepLongValue() {
93 // After first setup we should have a long string in the node
94 is(valueFront.shortValue.length, testSummaryLength, "After setup the test node should be truncated.");
95 ok(valueFront.incompleteValue, "After setup the node value should be incomplete.");
96 valueNode.nodeValue = longString;
97 gWalker.once("mutations", () => {
98 is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value");
99 ok(valueFront.incompleteValue, "Node value should stay incomplete.");
100 runNextTest();
101 });
102 }
104 function testSetShortValue() {
105 valueNode.nodeValue = shortString;
106 gWalker.once("mutations", () => {
107 is(valueFront.shortValue, shortString, "Value should not be truncated.");
108 ok(!valueFront.incompleteValue, "Value should not be incomplete.");
109 runNextTest();
110 });
111 }
113 function testKeepShortValue() {
114 valueNode.nodeValue = shortString2;
115 gWalker.once("mutations", () => {
116 is(valueFront.shortValue, shortString2, "Value should not be truncated.");
117 ok(!valueFront.incompleteValue, "Value should not be incomplete.");
118 runNextTest();
119 });
120 }
122 function testSetLongValue() {
123 valueNode.nodeValue = longString;
124 gWalker.once("mutations", () => {
125 is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value");
126 ok(valueFront.incompleteValue, "Node value should stay incomplete.");
127 runNextTest();
128 });
129 }
131 addTest(function cleanup() {
132 delete gInspectee;
133 delete gWalker;
134 delete gClient;
135 runNextTest();
136 });
139 </script>
140 </head>
141 <body>
142 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
143 <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
144 <p id="display"></p>
145 <div id="content" style="display: none">
147 </div>
148 <pre id="test">
149 </pre>
150 </body>
151 </html>