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 | <script type="application/javascript" src="head.js"/> |
michael@0 | 13 | <!-- test results are displayed in the html:body --> |
michael@0 | 14 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 15 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=809213" |
michael@0 | 16 | target="_blank">Mozilla Bug 809213</a> |
michael@0 | 17 | </body> |
michael@0 | 18 | |
michael@0 | 19 | <script type="application/javascript;version=1.8"> |
michael@0 | 20 | |
michael@0 | 21 | "use strict"; |
michael@0 | 22 | |
michael@0 | 23 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 24 | Components.utils.import("resource://gre/modules/PhoneNumberUtils.jsm"); |
michael@0 | 25 | |
michael@0 | 26 | Services.prefs.setIntPref("dom.phonenumber.substringmatching.BR", 8); |
michael@0 | 27 | Services.prefs.setCharPref("ril.lastKnownSimMcc", "724"); |
michael@0 | 28 | |
michael@0 | 29 | function CantParseWithMcc(dial, mcc) { |
michael@0 | 30 | var result = PhoneNumberUtils.parseWithMCC(dial, mcc); |
michael@0 | 31 | if (result) { |
michael@0 | 32 | ok(false, "Shouldn't parse!\n"); |
michael@0 | 33 | dump("expected: does not parse"); |
michael@0 | 34 | dump("got: " + dial + " " + mcc); |
michael@0 | 35 | } else { |
michael@0 | 36 | ok(true, "Parses"); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function ParseWithMcc(dial, mcc) { |
michael@0 | 41 | var result = PhoneNumberUtils.parseWithMCC(dial, mcc); |
michael@0 | 42 | if (result) { |
michael@0 | 43 | ok(true, "Parses!\n"); |
michael@0 | 44 | } else { |
michael@0 | 45 | ok(false, "Should Parse"); |
michael@0 | 46 | dump("expected: parses"); |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function FuzzyMatch(number1, number2, expect) { |
michael@0 | 51 | var result = PhoneNumberUtils.fuzzyMatch(number1, number2); |
michael@0 | 52 | is(result, expect, "FuzzyMatch OK!"); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | // Unknown mcc |
michael@0 | 56 | CantParseWithMcc("1234", 123); |
michael@0 | 57 | ParseWithMcc("4165555555", 302); |
michael@0 | 58 | |
michael@0 | 59 | is(PhoneNumberUtils.normalize("123abc", true), "123", "NumbersOnly"); |
michael@0 | 60 | is(PhoneNumberUtils.normalize("123abc", false), "123222", "NumbersOnly"); |
michael@0 | 61 | |
michael@0 | 62 | FuzzyMatch("123abc", "123222", true); |
michael@0 | 63 | FuzzyMatch("123456789", "123456789", true); |
michael@0 | 64 | FuzzyMatch("111", null, false); |
michael@0 | 65 | FuzzyMatch("+552155555555", "2155555555", true); |
michael@0 | 66 | FuzzyMatch("aaa123456789", "zzzzz123456789", true); |
michael@0 | 67 | </script> |
michael@0 | 68 | </window> |