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 | <?xml version="1.0"?> |
michael@0 | 2 | |
michael@0 | 3 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 5 | |
michael@0 | 6 | <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
michael@0 | 7 | <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> |
michael@0 | 8 | |
michael@0 | 9 | <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | title="Mozilla Bug 781379"> |
michael@0 | 11 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 12 | <!-- test results are displayed in the html:body --> |
michael@0 | 13 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 14 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=809213" |
michael@0 | 15 | target="_blank">Mozilla Bug 809213</a> |
michael@0 | 16 | </body> |
michael@0 | 17 | |
michael@0 | 18 | <script type="application/javascript;version=1.8"> |
michael@0 | 19 | |
michael@0 | 20 | "use strict"; |
michael@0 | 21 | |
michael@0 | 22 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 23 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 24 | |
michael@0 | 25 | Services.prefs.setIntPref("dom.phonenumber.substringmatching.BR", 8); |
michael@0 | 26 | Services.prefs.setCharPref("ril.lastKnownSimMcc", "724"); |
michael@0 | 27 | |
michael@0 | 28 | var pm = SpecialPowers.Cc["@mozilla.org/permissionmanager;1"] |
michael@0 | 29 | .getService(SpecialPowers.Ci.nsIPermissionManager); |
michael@0 | 30 | |
michael@0 | 31 | pm.addFromPrincipal(window.document.nodePrincipal, "phonenumberservice", |
michael@0 | 32 | SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION); |
michael@0 | 33 | |
michael@0 | 34 | function onUnwantedSuccess() { |
michael@0 | 35 | ok(false, "onUnwantedSuccess: shouldn't get here"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function onFailure() { |
michael@0 | 39 | ok(false, "in on Failure!"); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | var req; |
michael@0 | 43 | var index = 0; |
michael@0 | 44 | var mozPhoneNumberService = window.navigator.mozPhoneNumberService; |
michael@0 | 45 | ok(mozPhoneNumberService, "mozPhoneNumberService exists"); |
michael@0 | 46 | var steps = [ |
michael@0 | 47 | function() { |
michael@0 | 48 | req = mozPhoneNumberService.fuzzyMatch("123", "123"); |
michael@0 | 49 | req.onsuccess = function(e) { |
michael@0 | 50 | is(req.result, true, "same number"); |
michael@0 | 51 | next(); |
michael@0 | 52 | }; |
michael@0 | 53 | req.onerror = onFailure; |
michael@0 | 54 | }, |
michael@0 | 55 | function() { |
michael@0 | 56 | req = mozPhoneNumberService.fuzzyMatch("abcdef", "222333"); |
michael@0 | 57 | req.onsuccess = function(e) { |
michael@0 | 58 | is(req.result, true, "normalize first number"); |
michael@0 | 59 | next(); |
michael@0 | 60 | }; |
michael@0 | 61 | req.onerror = onFailure; |
michael@0 | 62 | }, |
michael@0 | 63 | function() { |
michael@0 | 64 | req = mozPhoneNumberService.fuzzyMatch("abc333", "222def"); |
michael@0 | 65 | req.onsuccess = function(e) { |
michael@0 | 66 | is(req.result, true, "normalize first and second number"); |
michael@0 | 67 | next(); |
michael@0 | 68 | }; |
michael@0 | 69 | req.onerror = onFailure; |
michael@0 | 70 | }, |
michael@0 | 71 | function() { |
michael@0 | 72 | req = mozPhoneNumberService.fuzzyMatch("1234567", "1234568"); |
michael@0 | 73 | req.onsuccess = function(e) { |
michael@0 | 74 | is(req.result, false, "different numbers should not match"); |
michael@0 | 75 | next(); |
michael@0 | 76 | }; |
michael@0 | 77 | req.onerror = onFailure; |
michael@0 | 78 | }, |
michael@0 | 79 | function() { |
michael@0 | 80 | req = mozPhoneNumberService.fuzzyMatch("1234567", "123456"); |
michael@0 | 81 | req.onsuccess = function(e) { |
michael@0 | 82 | is(req.result, false, "different length numbers should not match"); |
michael@0 | 83 | next(); |
michael@0 | 84 | }; |
michael@0 | 85 | req.onerror = onFailure; |
michael@0 | 86 | }, |
michael@0 | 87 | function() { |
michael@0 | 88 | req = mozPhoneNumberService.fuzzyMatch("1234567", "123456---"); |
michael@0 | 89 | req.onsuccess = function(e) { |
michael@0 | 90 | is(req.result, false, "invalid number should not match valid number"); |
michael@0 | 91 | next(); |
michael@0 | 92 | }; |
michael@0 | 93 | req.onerror = onFailure; |
michael@0 | 94 | }, |
michael@0 | 95 | function() { |
michael@0 | 96 | req = mozPhoneNumberService.fuzzyMatch("111", undefined); |
michael@0 | 97 | req.onsuccess = function(e) { |
michael@0 | 98 | is(req.result, false, "missing second argument should not match"); |
michael@0 | 99 | next(); |
michael@0 | 100 | }; |
michael@0 | 101 | req.onerror = onFailure; |
michael@0 | 102 | }, |
michael@0 | 103 | function() { |
michael@0 | 104 | req = mozPhoneNumberService.fuzzyMatch(undefined, "111"); |
michael@0 | 105 | req.onsuccess = function(e) { |
michael@0 | 106 | is(req.result, false, "missing first argument should not match"); |
michael@0 | 107 | next(); |
michael@0 | 108 | }; |
michael@0 | 109 | req.onerror = onFailure; |
michael@0 | 110 | }, |
michael@0 | 111 | function() { |
michael@0 | 112 | req = mozPhoneNumberService.fuzzyMatch(null, ""); |
michael@0 | 113 | req.onsuccess = function(e) { |
michael@0 | 114 | is(req.result, true, "missing first argument should fuzzy match empty string"); |
michael@0 | 115 | next(); |
michael@0 | 116 | }; |
michael@0 | 117 | req.onerror = onFailure; |
michael@0 | 118 | }, |
michael@0 | 119 | function() { |
michael@0 | 120 | req = mozPhoneNumberService.fuzzyMatch("+552155555555", "2155555555"); |
michael@0 | 121 | req.onsuccess = function(e) { |
michael@0 | 122 | is(req.result, true, "test internationalization of number"); |
michael@0 | 123 | next(); |
michael@0 | 124 | }; |
michael@0 | 125 | req.onerror = onFailure; |
michael@0 | 126 | }, |
michael@0 | 127 | function() { |
michael@0 | 128 | req = mozPhoneNumberService.fuzzyMatch("aaa123456789", "zzzzz123456789"); |
michael@0 | 129 | req.onsuccess = function(e) { |
michael@0 | 130 | is(req.result, true, "substring matching should be in effect"); |
michael@0 | 131 | next(); |
michael@0 | 132 | }; |
michael@0 | 133 | req.onerror = onFailure; |
michael@0 | 134 | }, |
michael@0 | 135 | function () { |
michael@0 | 136 | ok(true, "all done!\n"); |
michael@0 | 137 | SimpleTest.finish(); |
michael@0 | 138 | } |
michael@0 | 139 | ]; |
michael@0 | 140 | |
michael@0 | 141 | function next() { |
michael@0 | 142 | ok(true, "Begin!"); |
michael@0 | 143 | if (index >= steps.length) { |
michael@0 | 144 | ok(false, "Shouldn't get here!"); |
michael@0 | 145 | return; |
michael@0 | 146 | } |
michael@0 | 147 | try { |
michael@0 | 148 | var i = index++; |
michael@0 | 149 | steps[i](); |
michael@0 | 150 | } catch(ex) { |
michael@0 | 151 | ok(false, "Caught exception", ex); |
michael@0 | 152 | } |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 156 | addLoadEvent(next); |
michael@0 | 157 | </script> |
michael@0 | 158 | </window> |