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 | SpecialPowers.addPermission("mobileconnection", true, document); |
michael@0 | 5 | |
michael@0 | 6 | // In single sim scenario, there is only one mobileConnection, we can always use |
michael@0 | 7 | // the first instance. |
michael@0 | 8 | let mobileConnection = window.navigator.mozMobileConnections[0]; |
michael@0 | 9 | ok(mobileConnection instanceof MozMobileConnection, |
michael@0 | 10 | "mobileConnection is instanceof " + mobileConnection.constructor); |
michael@0 | 11 | |
michael@0 | 12 | let _pendingEmulatorCmdCount = 0; |
michael@0 | 13 | |
michael@0 | 14 | /* Remove permission and execute finish() */ |
michael@0 | 15 | let cleanUp = function() { |
michael@0 | 16 | waitFor(function() { |
michael@0 | 17 | SpecialPowers.removePermission("mobileconnection", document); |
michael@0 | 18 | finish(); |
michael@0 | 19 | }, function() { |
michael@0 | 20 | return _pendingEmulatorCmdCount === 0; |
michael@0 | 21 | }); |
michael@0 | 22 | }; |
michael@0 | 23 | |
michael@0 | 24 | /* Helper for tasks */ |
michael@0 | 25 | let taskHelper = { |
michael@0 | 26 | tasks: [], |
michael@0 | 27 | |
michael@0 | 28 | push: function(task) { |
michael@0 | 29 | this.tasks.push(task); |
michael@0 | 30 | }, |
michael@0 | 31 | |
michael@0 | 32 | runNext: function() { |
michael@0 | 33 | let task = this.tasks.shift(); |
michael@0 | 34 | if (!task) { |
michael@0 | 35 | cleanUp(); |
michael@0 | 36 | return; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | if (typeof task === "function") { |
michael@0 | 40 | task(); |
michael@0 | 41 | } |
michael@0 | 42 | }, |
michael@0 | 43 | }; |
michael@0 | 44 | |
michael@0 | 45 | /* Helper for emulator console command */ |
michael@0 | 46 | let emulatorHelper = { |
michael@0 | 47 | sendCommand: function(cmd, callback) { |
michael@0 | 48 | _pendingEmulatorCmdCount++; |
michael@0 | 49 | runEmulatorCmd(cmd, function(results) { |
michael@0 | 50 | _pendingEmulatorCmdCount--; |
michael@0 | 51 | |
michael@0 | 52 | let result = results[results.length - 1]; |
michael@0 | 53 | is(result, "OK", "'"+ cmd +"' returns '" + result + "'"); |
michael@0 | 54 | |
michael@0 | 55 | if (callback && typeof callback === "function") { |
michael@0 | 56 | callback(results); |
michael@0 | 57 | } |
michael@0 | 58 | }); |
michael@0 | 59 | }, |
michael@0 | 60 | }; |