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 | 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 connection; |
michael@0 | 12 | ifr.onload = function() { |
michael@0 | 13 | connection = ifr.contentWindow.navigator.mozMobileConnections[0]; |
michael@0 | 14 | |
michael@0 | 15 | ok(connection instanceof ifr.contentWindow.MozMobileConnection, |
michael@0 | 16 | "connection is instanceof " + connection.constructor); |
michael@0 | 17 | |
michael@0 | 18 | nextTest(); |
michael@0 | 19 | }; |
michael@0 | 20 | document.body.appendChild(ifr); |
michael@0 | 21 | |
michael@0 | 22 | let caseId = 0; |
michael@0 | 23 | let options = [ |
michael@0 | 24 | buildOption(5, true, '0000', 0), // invalid program. |
michael@0 | 25 | |
michael@0 | 26 | // test null. |
michael@0 | 27 | buildOption(null, true, '0000', 0), |
michael@0 | 28 | buildOption(0, null, '0000', 0), |
michael@0 | 29 | buildOption(0, true, null, 0), |
michael@0 | 30 | buildOption(0, true, '0000', null), |
michael@0 | 31 | |
michael@0 | 32 | // test undefined. |
michael@0 | 33 | {'enabled': true, 'password': '0000', 'serviceClass': 0}, |
michael@0 | 34 | {'program': 0, 'password': '0000', 'serviceClass': 0}, |
michael@0 | 35 | {'program': 0, 'enabled': true, 'serviceClass': 0}, |
michael@0 | 36 | {'program': 0, 'enabled': true, 'password': '0000'}, |
michael@0 | 37 | ]; |
michael@0 | 38 | |
michael@0 | 39 | function buildOption(program, enabled, password, serviceClass) { |
michael@0 | 40 | return { |
michael@0 | 41 | 'program': program, |
michael@0 | 42 | 'enabled': enabled, |
michael@0 | 43 | 'password': password, |
michael@0 | 44 | 'serviceClass': serviceClass |
michael@0 | 45 | }; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function testSetCallBarringOptionError(option) { |
michael@0 | 49 | let request = connection.setCallBarringOption(option); |
michael@0 | 50 | request.onsuccess = function() { |
michael@0 | 51 | ok(false, |
michael@0 | 52 | 'should not fire onsuccess for invaild call barring option: ' |
michael@0 | 53 | + JSON.stringify(option)); |
michael@0 | 54 | }; |
michael@0 | 55 | request.onerror = function(event) { |
michael@0 | 56 | is(event.target.error.name, 'InvalidParameter', JSON.stringify(option)); |
michael@0 | 57 | nextTest(); |
michael@0 | 58 | }; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function nextTest() { |
michael@0 | 62 | if (caseId >= options.length) { |
michael@0 | 63 | cleanUp(); |
michael@0 | 64 | } else { |
michael@0 | 65 | let option = options[caseId++]; |
michael@0 | 66 | log('test for ' + JSON.stringify(option)); |
michael@0 | 67 | testSetCallBarringOptionError(option); |
michael@0 | 68 | } |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function cleanUp() { |
michael@0 | 72 | SpecialPowers.removePermission("mobileconnection", document); |
michael@0 | 73 | finish(); |
michael@0 | 74 | } |