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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | MARIONETTE_TIMEOUT = 60000; |
michael@0 | 5 | |
michael@0 | 6 | const SELF = "5554"; |
michael@0 | 7 | |
michael@0 | 8 | SpecialPowers.setBoolPref("dom.sms.enabled", true); |
michael@0 | 9 | SpecialPowers.addPermission("sms", true, document); |
michael@0 | 10 | |
michael@0 | 11 | function cleanUp() { |
michael@0 | 12 | SpecialPowers.removePermission("sms", document); |
michael@0 | 13 | SpecialPowers.clearUserPref("dom.sms.enabled"); |
michael@0 | 14 | finish(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | let manager = window.navigator.mozMobileMessage; |
michael@0 | 18 | ok(manager instanceof MozMobileMessageManager, |
michael@0 | 19 | "manager is instance of " + manager.constructor); |
michael@0 | 20 | |
michael@0 | 21 | function randomString16() { |
michael@0 | 22 | return Math.random().toString(36).substr(2, 16); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function times(str, n) { |
michael@0 | 26 | return (new Array(n + 1)).join(str); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function repeat(func, array, oncomplete) { |
michael@0 | 30 | (function do_call(index) { |
michael@0 | 31 | let next = index < (array.length - 1) ? do_call.bind(null, index + 1) : oncomplete; |
michael@0 | 32 | func.apply(null, [array[index], next]); |
michael@0 | 33 | })(0); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function doTest(body, callback) { |
michael@0 | 37 | manager.addEventListener("received", function onReceived(event) { |
michael@0 | 38 | event.target.removeEventListener(event.type, arguments.callee); |
michael@0 | 39 | |
michael@0 | 40 | let message = event.message; |
michael@0 | 41 | is(message.body, body, "message.body"); |
michael@0 | 42 | |
michael@0 | 43 | window.setTimeout(callback, 0); |
michael@0 | 44 | }); |
michael@0 | 45 | |
michael@0 | 46 | let request = manager.send(SELF, body); |
michael@0 | 47 | request.onerror = function onerror() { |
michael@0 | 48 | ok(false, "failed to send message '" + body + "' to '" + SELF + "'"); |
michael@0 | 49 | }; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | repeat(doTest, [ |
michael@0 | 53 | // Random alphanumeric string of 16 characters. |
michael@0 | 54 | randomString16(), |
michael@0 | 55 | // Long long text message for multipart messages. |
michael@0 | 56 | times(randomString16(), 100), |
michael@0 | 57 | |
michael@0 | 58 | // UCS2 string for the first sentence of "The Cooing", Classic of Poetry. |
michael@0 | 59 | "\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002", |
michael@0 | 60 | // Long long UCS2 text message for multipart messages. |
michael@0 | 61 | times("\u95dc\u95dc\u96ce\u9ce9\uff0c\u5728\u6cb3\u4e4b\u6d32\u3002", 100), |
michael@0 | 62 | |
michael@0 | 63 | // Test case from Bug 809553 |
michael@0 | 64 | "zertuuuppzuzyeueieieyeieoeiejeheejrueufjfjfjjfjfkxifjfjfufjjfjfufujdjduxxjdu" |
michael@0 | 65 | + "djdjdjdudhdjdhdjdbddhbfjfjxbuwjdjdudjddjdhdhdvdyudusjdudhdjjfjdvdudbddjdbd" |
michael@0 | 66 | + "usjfbjdfudjdhdjbzuuzyzehdjjdjwybwudjvwywuxjdbfudsbwuwbwjdjdbwywhdbddudbdjd" |
michael@0 | 67 | + "uejdhdudbdduwjdbjddudjdjdjdudjdbdjdhdhdjjdjbxudjdbxufjudbdjhdjdisjsjzusbzh" |
michael@0 | 68 | + "xbdudksksuqjgdjdb jeudi jeudis duhebevzcevevsvs DVD suscite eh du d des jv" |
michael@0 | 69 | + " y b Dj. Du wh. Hu Deb wh. Du web h w show d DVD h w v. Th\u00e9 \u00e9c" |
michael@0 | 70 | + "hec d whdvdj. Wh d'h\u00f4tel DVD. IMAX eusjw ii ce", |
michael@0 | 71 | |
michael@0 | 72 | // Android Emulator specific problems: |
michael@0 | 73 | // 1) wrong default 7Bit alphabet character for "Ň"(U+0147). |
michael@0 | 74 | "\u0147", |
michael@0 | 75 | // 2) problem in decoding strings encoded with GSM 7Bit Alphabets and |
michael@0 | 76 | // containing characters on extension tables. |
michael@0 | 77 | "\u20ac****", |
michael@0 | 78 | ], cleanUp); |