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 = 20000; |
michael@0 | 5 | |
michael@0 | 6 | SpecialPowers.addPermission("mobileconnection", true, document); |
michael@0 | 7 | |
michael@0 | 8 | // Permission changes can't change existing Navigator.prototype |
michael@0 | 9 | // objects, so grab our objects from a new Navigator |
michael@0 | 10 | let ifr = document.createElement("iframe"); |
michael@0 | 11 | let mobileConnection; |
michael@0 | 12 | ifr.onload = function() { |
michael@0 | 13 | mobileConnection = ifr.contentWindow.navigator.mozMobileConnections[0]; |
michael@0 | 14 | |
michael@0 | 15 | tasks.run(); |
michael@0 | 16 | }; |
michael@0 | 17 | document.body.appendChild(ifr); |
michael@0 | 18 | |
michael@0 | 19 | let tasks = { |
michael@0 | 20 | // List of test functions. Each of them should call |tasks.next()| when |
michael@0 | 21 | // completed or |tasks.abort()| to jump to the last one. |
michael@0 | 22 | _tasks: [], |
michael@0 | 23 | _nextTaskIndex: 0, |
michael@0 | 24 | |
michael@0 | 25 | push: function(func) { |
michael@0 | 26 | this._tasks.push(func); |
michael@0 | 27 | }, |
michael@0 | 28 | |
michael@0 | 29 | next: function() { |
michael@0 | 30 | let index = this._nextTaskIndex++; |
michael@0 | 31 | let task = this._tasks[index]; |
michael@0 | 32 | try { |
michael@0 | 33 | task(); |
michael@0 | 34 | } catch (ex) { |
michael@0 | 35 | ok(false, "test task[" + index + "] throws: " + ex); |
michael@0 | 36 | // Run last task as clean up if possible. |
michael@0 | 37 | if (index != this._tasks.length - 1) { |
michael@0 | 38 | this.abort(); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | }, |
michael@0 | 42 | |
michael@0 | 43 | abort: function() { |
michael@0 | 44 | this._tasks[this._tasks.length - 1](); |
michael@0 | 45 | }, |
michael@0 | 46 | |
michael@0 | 47 | run: function() { |
michael@0 | 48 | this.next(); |
michael@0 | 49 | } |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | tasks.push(function verifyInitialState() { |
michael@0 | 53 | log("Verifying initial state."); |
michael@0 | 54 | |
michael@0 | 55 | ok(mobileConnection instanceof ifr.contentWindow.MozMobileConnection, |
michael@0 | 56 | "mobileConnection is instanceof " + mobileConnection.constructor); |
michael@0 | 57 | |
michael@0 | 58 | tasks.next(); |
michael@0 | 59 | }); |
michael@0 | 60 | |
michael@0 | 61 | tasks.push(function testGettingIMEI() { |
michael@0 | 62 | log("Test *#06# ..."); |
michael@0 | 63 | |
michael@0 | 64 | let request = mobileConnection.sendMMI("*#06#"); |
michael@0 | 65 | ok(request instanceof DOMRequest, |
michael@0 | 66 | "request is instanceof " + request.constructor); |
michael@0 | 67 | |
michael@0 | 68 | request.onsuccess = function onsuccess(event) { |
michael@0 | 69 | ok(true, "request success"); |
michael@0 | 70 | is(typeof event.target.result, "object", "typeof result object"); |
michael@0 | 71 | ok(event.target.result instanceof Object, "result instanceof Object"); |
michael@0 | 72 | is(event.target.result.statusMessage, "000000000000000", "Emulator IMEI"); |
michael@0 | 73 | is(event.target.result.serviceCode, "scImei", "Service code IMEI"); |
michael@0 | 74 | is(event.target.result.additionalInformation, undefined, |
michael@0 | 75 | "No additional information"); |
michael@0 | 76 | tasks.next(); |
michael@0 | 77 | } |
michael@0 | 78 | request.onerror = function onerror() { |
michael@0 | 79 | ok(false, "request should not error"); |
michael@0 | 80 | tasks.abort(); |
michael@0 | 81 | }; |
michael@0 | 82 | }); |
michael@0 | 83 | |
michael@0 | 84 | tasks.push(function testInvalidMMICode(){ |
michael@0 | 85 | log("Test invalid MMI code ..."); |
michael@0 | 86 | |
michael@0 | 87 | let request = mobileConnection.sendMMI("InvalidMMICode"); |
michael@0 | 88 | ok(request instanceof DOMRequest, |
michael@0 | 89 | "request is instanceof " + request.constructor); |
michael@0 | 90 | |
michael@0 | 91 | request.onsuccess = function onsuccess(event) { |
michael@0 | 92 | ok(false, "request should not success"); |
michael@0 | 93 | tasks.abort(); |
michael@0 | 94 | }; |
michael@0 | 95 | |
michael@0 | 96 | request.onerror = function onerror() { |
michael@0 | 97 | ok(true, "request error"); |
michael@0 | 98 | is(request.error.name, "emMmiError", "MMI error name"); |
michael@0 | 99 | tasks.next(); |
michael@0 | 100 | }; |
michael@0 | 101 | }); |
michael@0 | 102 | |
michael@0 | 103 | // WARNING: All tasks should be pushed before this!!! |
michael@0 | 104 | tasks.push(function cleanUp() { |
michael@0 | 105 | SpecialPowers.removePermission("mobileconnection", document); |
michael@0 | 106 | finish(); |
michael@0 | 107 | }); |