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.
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 | const testSummaryLength = 10; |
michael@0 | 25 | inspector.setValueSummaryLength(testSummaryLength); |
michael@0 | 26 | SimpleTest.registerCleanupFunction(function() { |
michael@0 | 27 | inspector.setValueSummaryLength(inspector.DEFAULT_VALUE_SUMMARY_LENGTH); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | var gInspectee = null; |
michael@0 | 31 | var gWalker = null; |
michael@0 | 32 | var gClient = null; |
michael@0 | 33 | var valueNode; |
michael@0 | 34 | var valueFront; |
michael@0 | 35 | var longString = "stringstringstringstringstringstringstringstringstringstringstring"; |
michael@0 | 36 | var truncatedLongString = longString.substring(0, testSummaryLength); |
michael@0 | 37 | var shortString = "str"; |
michael@0 | 38 | var shortString2 = "str2"; |
michael@0 | 39 | |
michael@0 | 40 | addTest(function setup() { |
michael@0 | 41 | let url = document.getElementById("inspectorContent").href; |
michael@0 | 42 | attachURL(url, function(err, client, tab, doc) { |
michael@0 | 43 | gInspectee = doc; |
michael@0 | 44 | let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); |
michael@0 | 45 | let inspector = InspectorFront(client, tab); |
michael@0 | 46 | promiseDone(inspector.getWalker().then(walker => { |
michael@0 | 47 | ok(walker, "getWalker() should return an actor."); |
michael@0 | 48 | gClient = client; |
michael@0 | 49 | gWalker = walker; |
michael@0 | 50 | }).then(runNextTest)); |
michael@0 | 51 | }); |
michael@0 | 52 | }); |
michael@0 | 53 | |
michael@0 | 54 | addTest(setupValueTest); |
michael@0 | 55 | addTest(testKeepLongValue); |
michael@0 | 56 | addTest(testSetShortValue); |
michael@0 | 57 | addTest(testKeepShortValue); |
michael@0 | 58 | addTest(testSetLongValue); |
michael@0 | 59 | addTest(setupFrameValueTest); |
michael@0 | 60 | addTest(testKeepLongValue); |
michael@0 | 61 | addTest(testSetShortValue); |
michael@0 | 62 | addTest(testKeepShortValue); |
michael@0 | 63 | addTest(testSetLongValue); |
michael@0 | 64 | |
michael@0 | 65 | function setupValueTest() { |
michael@0 | 66 | valueNode = gInspectee.querySelector("#longstring").firstChild; |
michael@0 | 67 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#longstring").then(node => { |
michael@0 | 68 | return gWalker.children(node); |
michael@0 | 69 | }).then(children => { |
michael@0 | 70 | valueFront = children.nodes[0]; |
michael@0 | 71 | }).then(runNextTest)); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | function setupFrameValueTest() { |
michael@0 | 75 | let frame = gInspectee.querySelector('#childFrame'); |
michael@0 | 76 | valueNode = frame.contentDocument.querySelector("#longstring").firstChild; |
michael@0 | 77 | |
michael@0 | 78 | promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => { |
michael@0 | 79 | return gWalker.children(childFrame); |
michael@0 | 80 | }).then(children => { |
michael@0 | 81 | let nodes = children.nodes; |
michael@0 | 82 | ok(nodes.length, 1, "There should be only one child of the iframe"); |
michael@0 | 83 | is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node"); |
michael@0 | 84 | return gWalker.querySelector(nodes[0], "#longstring"); |
michael@0 | 85 | }).then(node => { |
michael@0 | 86 | return gWalker.children(node); |
michael@0 | 87 | }).then(children => { |
michael@0 | 88 | valueFront = children.nodes[0]; |
michael@0 | 89 | }).then(runNextTest)); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function testKeepLongValue() { |
michael@0 | 93 | // After first setup we should have a long string in the node |
michael@0 | 94 | is(valueFront.shortValue.length, testSummaryLength, "After setup the test node should be truncated."); |
michael@0 | 95 | ok(valueFront.incompleteValue, "After setup the node value should be incomplete."); |
michael@0 | 96 | valueNode.nodeValue = longString; |
michael@0 | 97 | gWalker.once("mutations", () => { |
michael@0 | 98 | is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value"); |
michael@0 | 99 | ok(valueFront.incompleteValue, "Node value should stay incomplete."); |
michael@0 | 100 | runNextTest(); |
michael@0 | 101 | }); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function testSetShortValue() { |
michael@0 | 105 | valueNode.nodeValue = shortString; |
michael@0 | 106 | gWalker.once("mutations", () => { |
michael@0 | 107 | is(valueFront.shortValue, shortString, "Value should not be truncated."); |
michael@0 | 108 | ok(!valueFront.incompleteValue, "Value should not be incomplete."); |
michael@0 | 109 | runNextTest(); |
michael@0 | 110 | }); |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | function testKeepShortValue() { |
michael@0 | 114 | valueNode.nodeValue = shortString2; |
michael@0 | 115 | gWalker.once("mutations", () => { |
michael@0 | 116 | is(valueFront.shortValue, shortString2, "Value should not be truncated."); |
michael@0 | 117 | ok(!valueFront.incompleteValue, "Value should not be incomplete."); |
michael@0 | 118 | runNextTest(); |
michael@0 | 119 | }); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | function testSetLongValue() { |
michael@0 | 123 | valueNode.nodeValue = longString; |
michael@0 | 124 | gWalker.once("mutations", () => { |
michael@0 | 125 | is(valueFront.shortValue, truncatedLongString, "Value should have changed to a truncated value"); |
michael@0 | 126 | ok(valueFront.incompleteValue, "Node value should stay incomplete."); |
michael@0 | 127 | runNextTest(); |
michael@0 | 128 | }); |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | addTest(function cleanup() { |
michael@0 | 132 | delete gInspectee; |
michael@0 | 133 | delete gWalker; |
michael@0 | 134 | delete gClient; |
michael@0 | 135 | runNextTest(); |
michael@0 | 136 | }); |
michael@0 | 137 | |
michael@0 | 138 | |
michael@0 | 139 | </script> |
michael@0 | 140 | </head> |
michael@0 | 141 | <body> |
michael@0 | 142 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> |
michael@0 | 143 | <a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> |
michael@0 | 144 | <p id="display"></p> |
michael@0 | 145 | <div id="content" style="display: none"> |
michael@0 | 146 | |
michael@0 | 147 | </div> |
michael@0 | 148 | <pre id="test"> |
michael@0 | 149 | </pre> |
michael@0 | 150 | </body> |
michael@0 | 151 | </html> |