dom/mobilemessage/tests/marionette/test_emulator_loopback.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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

mercurial