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 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 4 | <html> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test for Alerts Service</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 9 | </head> |
michael@0 | 10 | |
michael@0 | 11 | <body> |
michael@0 | 12 | <p id="display"></p> |
michael@0 | 13 | |
michael@0 | 14 | <br>Alerts service, with observer "synchronous" case. |
michael@0 | 15 | <br> |
michael@0 | 16 | <br>Did a notification appear anywhere? |
michael@0 | 17 | <br>If so, the test will finish once the notification disappears. |
michael@0 | 18 | |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | var observer = { |
michael@0 | 23 | alertShow: false, |
michael@0 | 24 | observe: function (aSubject, aTopic, aData) { |
michael@0 | 25 | if (aTopic == "alertclickcallback") { |
michael@0 | 26 | todo(false, "Did someone click the notification while running mochitests? (Please don't.)"); |
michael@0 | 27 | } else if (aTopic == "alertshow") { |
michael@0 | 28 | ok(!this.alertShow, "Alert should not be shown more than once"); |
michael@0 | 29 | this.alertShow = true; |
michael@0 | 30 | } else { |
michael@0 | 31 | is(aTopic, "alertfinished", "Checking the topic for a finished notification"); |
michael@0 | 32 | SimpleTest.finish(); |
michael@0 | 33 | } |
michael@0 | 34 | is(aData, "foobarcookie", "Checking whether the alert cookie was passed correctly"); |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | function runTest() { |
michael@0 | 39 | const Cc = SpecialPowers.Cc; |
michael@0 | 40 | const Ci = SpecialPowers.Ci; |
michael@0 | 41 | |
michael@0 | 42 | if (!("@mozilla.org/alerts-service;1" in Cc)) { |
michael@0 | 43 | todo(false, "Alerts service does not exist in this application"); |
michael@0 | 44 | return; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | ok(true, "Alerts service exists in this application"); |
michael@0 | 48 | |
michael@0 | 49 | var notifier; |
michael@0 | 50 | try { |
michael@0 | 51 | notifier = Cc["@mozilla.org/alerts-service;1"]. |
michael@0 | 52 | getService(Ci.nsIAlertsService); |
michael@0 | 53 | ok(true, "Alerts service is available"); |
michael@0 | 54 | } catch (ex) { |
michael@0 | 55 | todo(false, |
michael@0 | 56 | "Alerts service is not available.", ex); |
michael@0 | 57 | return; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | try { |
michael@0 | 61 | var alertName = "fiorello"; |
michael@0 | 62 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 63 | notifier.showAlertNotification(null, "Notification test", |
michael@0 | 64 | "Surprise! I'm here to test notifications!", |
michael@0 | 65 | false, "foobarcookie", observer, alertname); |
michael@0 | 66 | ok(true, "showAlertNotification() succeeded. Waiting for notification..."); |
michael@0 | 67 | if (MAC) { |
michael@0 | 68 | // Notifications are native on OS X 10.8 and later, and when they are they |
michael@0 | 69 | // persist in the Notification Center. We need to close explicitly to avoid a hang. |
michael@0 | 70 | // This also works for XUL notifications when running this test on OS X < 10.8. |
michael@0 | 71 | notifier.closeAlert(alertName); |
michael@0 | 72 | } |
michael@0 | 73 | } catch (ex) { |
michael@0 | 74 | todo(false, "showAlertNotification() failed.", ex); |
michael@0 | 75 | SimpleTest.finish(); |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | runTest(); |
michael@0 | 80 | |
michael@0 | 81 | </script> |
michael@0 | 82 | </pre> |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |