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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for WebSMS</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | <iframe></iframe> |
michael@0 | 12 | </div> |
michael@0 | 13 | <pre id="test"> |
michael@0 | 14 | <script type="application/javascript"> |
michael@0 | 15 | var defaultEnabled = ('mozMobileMessage' in frames[0].navigator); |
michael@0 | 16 | |
michael@0 | 17 | /** Test for WebSMS **/ |
michael@0 | 18 | |
michael@0 | 19 | function checkSmsDisabled() { |
michael@0 | 20 | ok(!('mozMobileMessage' in frames[0].navigator), "navigator.mozMobileMessage should not exist"); |
michael@0 | 21 | ok(frames[0].navigator.mozMobileMessage === undefined, |
michael@0 | 22 | "navigator.mozMobileMessage should return undefined"); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function checkSmsEnabled() { |
michael@0 | 26 | // Bug 784617: WebSms is disabled on all platforms except Android for the moment. |
michael@0 | 27 | if (navigator.appVersion.indexOf("Android") == -1 && SpecialPowers.Services.appinfo.name != "B2G") { |
michael@0 | 28 | checkSmsDisabled(); |
michael@0 | 29 | return; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | ok('mozMobileMessage' in frames[0].navigator, "navigator.mozMobileMessage should exist"); |
michael@0 | 33 | ok(frames[0].navigator.mozMobileMessage, "navigator.mozMobileMessage returns an object"); |
michael@0 | 34 | ok(frames[0].navigator.mozMobileMessage instanceof MozMobileMessageManager, |
michael@0 | 35 | "navigator.mozMobileMessage is an MobileMessageManager object"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function checkSmsDisabledOrEnabled() { |
michael@0 | 39 | if (!defaultEnabled) |
michael@0 | 40 | checkSmsDisabled(); |
michael@0 | 41 | else |
michael@0 | 42 | checkSmsEnabled(); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function checkInterface(aInterface) { |
michael@0 | 46 | ok(!(aInterface in window), aInterface + " should be prefixed"); |
michael@0 | 47 | ok(("Moz" + aInterface) in window, aInterface + " should be prefixed"); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function test() { |
michael@0 | 51 | checkInterface("SmsMessage"); |
michael@0 | 52 | checkInterface("SmsEvent"); |
michael@0 | 53 | checkInterface("SmsFilter"); |
michael@0 | 54 | |
michael@0 | 55 | // If sms is disabled and permission is removed, sms is disabled. |
michael@0 | 56 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() { |
michael@0 | 57 | SpecialPowers.pushPermissions([{'type': 'sms', 'remove': true, 'context': document}], test2); |
michael@0 | 58 | }); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function test2() { |
michael@0 | 62 | checkSmsDisabledOrEnabled(); |
michael@0 | 63 | |
michael@0 | 64 | // If sms is enabled and permission is removed, sms is disabled. |
michael@0 | 65 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() { |
michael@0 | 66 | SpecialPowers.pushPermissions([{'type': 'sms', 'remove': true, 'context': document}], test3); |
michael@0 | 67 | }); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | function test3() { |
michael@0 | 71 | checkSmsDisabledOrEnabled(); |
michael@0 | 72 | |
michael@0 | 73 | // If sms is disabled and permission is granted, sms is disabled. |
michael@0 | 74 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() { |
michael@0 | 75 | SpecialPowers.pushPermissions([{'type': 'sms', 'allow': true, 'context': document}], test4); |
michael@0 | 76 | }); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function test4() { |
michael@0 | 80 | checkSmsDisabledOrEnabled(); |
michael@0 | 81 | |
michael@0 | 82 | // If sms is enabled and permission is granted, sms is enabled. |
michael@0 | 83 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() { |
michael@0 | 84 | SpecialPowers.pushPermissions([{'type': 'sms', 'allow': true, 'context': document}], test5); |
michael@0 | 85 | }); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function test5() { |
michael@0 | 89 | checkSmsDisabledOrEnabled(); |
michael@0 | 90 | |
michael@0 | 91 | // Now, if sms are disabled with the pref, they will still be enabled. |
michael@0 | 92 | // The page has to be reloaded. |
michael@0 | 93 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, test6); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | function test6() { |
michael@0 | 97 | checkSmsDisabledOrEnabled(); |
michael@0 | 98 | |
michael@0 | 99 | var iframeElt = document.getElementsByTagName('iframe')[0]; |
michael@0 | 100 | iframeElt.addEventListener("load", function() { |
michael@0 | 101 | iframeElt.removeEventListener("load", arguments.callee); |
michael@0 | 102 | checkSmsEnabled(); |
michael@0 | 103 | |
michael@0 | 104 | iframeElt.addEventListener("load", function() { |
michael@0 | 105 | iframeElt.removeEventListener("load", arguments.callee); |
michael@0 | 106 | |
michael@0 | 107 | checkSmsDisabled(); |
michael@0 | 108 | |
michael@0 | 109 | SimpleTest.finish(); |
michael@0 | 110 | }); |
michael@0 | 111 | |
michael@0 | 112 | // Disabling sms takes effect on reload. |
michael@0 | 113 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() { |
michael@0 | 114 | frames[0].location.reload(); |
michael@0 | 115 | }); |
michael@0 | 116 | }); |
michael@0 | 117 | |
michael@0 | 118 | SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() { |
michael@0 | 119 | frames[0].location.reload(); |
michael@0 | 120 | }); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 124 | addLoadEvent(test); |
michael@0 | 125 | |
michael@0 | 126 | </script> |
michael@0 | 127 | </pre> |
michael@0 | 128 | </body> |
michael@0 | 129 | </html> |