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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=989806 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 989806</title> |
michael@0 | 9 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | <script type="text/javascript" src="test_packaged_app_common.js"></script> |
michael@0 | 12 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 13 | </head> |
michael@0 | 14 | <body> |
michael@0 | 15 | |
michael@0 | 16 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=989806">Mozilla Bug 989806</a> |
michael@0 | 17 | <p id="display"></p> |
michael@0 | 18 | <div id="content" style="display: none"> |
michael@0 | 19 | |
michael@0 | 20 | </div> |
michael@0 | 21 | <pre id="test"> |
michael@0 | 22 | <script class="testbody" type="application/javascript;version=1.7"> |
michael@0 | 23 | |
michael@0 | 24 | "use strict"; |
michael@0 | 25 | |
michael@0 | 26 | let gApp = null; |
michael@0 | 27 | |
michael@0 | 28 | let gExternalInstallOrigin = "http://mochi.test:8888/"; |
michael@0 | 29 | let gExternalAppsPath = gExternalInstallOrigin + "tests/dom/apps/tests/marketplace/"; |
michael@0 | 30 | |
michael@0 | 31 | let gMarketplaceInstallOrigin = "https://marketplace.firefox.com/"; |
michael@0 | 32 | let gMarketplaceAppsPath = gMarketplaceInstallOrigin + "tests/dom/apps/tests/marketplace/"; |
michael@0 | 33 | |
michael@0 | 34 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 35 | |
michael@0 | 36 | function checkAppOnInstallSuccess(aExpected) { |
michael@0 | 37 | navigator.mozApps.mgmt.oninstall = function(evt) { |
michael@0 | 38 | info("Got oninstall event"); |
michael@0 | 39 | gApp = evt.application; |
michael@0 | 40 | gApp.ondownloaderror = function() { |
michael@0 | 41 | ok(false, "Download should succeed (got error: " + |
michael@0 | 42 | gApp.downloadError.name + ")"); |
michael@0 | 43 | PackagedTestHelper.finish(); |
michael@0 | 44 | }; |
michael@0 | 45 | gApp.ondownloadsuccess = function() { |
michael@0 | 46 | info("App downloaded"); |
michael@0 | 47 | PackagedTestHelper.checkAppState(gApp, aExpected.version, aExpected, |
michael@0 | 48 | true, true, PackagedTestHelper.next); |
michael@0 | 49 | }; |
michael@0 | 50 | }; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function checkAppOnInstallError(aExpectedError) { |
michael@0 | 54 | navigator.mozApps.mgmt.oninstall = function(evt) { |
michael@0 | 55 | info("Got oninstall event"); |
michael@0 | 56 | gApp = evt.application; |
michael@0 | 57 | gApp.ondownloaderror = function() { |
michael@0 | 58 | is(gApp.downloadError.name, aExpectedError, |
michael@0 | 59 | "Download fails with expected error: " + aExpectedError); |
michael@0 | 60 | if (gApp.downloadError.name != aExpectedError) { |
michael@0 | 61 | PackagedTestHelper.finish(); |
michael@0 | 62 | } else { |
michael@0 | 63 | PackagedTestHelper.next(); |
michael@0 | 64 | } |
michael@0 | 65 | }; |
michael@0 | 66 | gApp.ondownloadsuccess = function() { |
michael@0 | 67 | ok(false, "App download should fail"); |
michael@0 | 68 | PackagedTestHelper.finish(); |
michael@0 | 69 | }; |
michael@0 | 70 | }; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function checkUninstallApp(aApp) { |
michael@0 | 74 | let req = navigator.mozApps.mgmt.uninstall(aApp); |
michael@0 | 75 | |
michael@0 | 76 | req.onsuccess = function() { |
michael@0 | 77 | info("App uninstalled"); |
michael@0 | 78 | aApp.ondownloadsuccess = null; |
michael@0 | 79 | aApp.ondownloaderror = null; |
michael@0 | 80 | aApp.onprogress = null; |
michael@0 | 81 | PackagedTestHelper.next(); |
michael@0 | 82 | }; |
michael@0 | 83 | req.onerror = function(evt) { |
michael@0 | 84 | ok(false, "App uninstallation should succeed (got unexpected " + |
michael@0 | 85 | evt.target.error.name + ")"); |
michael@0 | 86 | PackagedTestHelper.finish(); |
michael@0 | 87 | }; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function installApp(installOrigin, manifestURL) { |
michael@0 | 91 | let domParent = document.getElementById('container'); |
michael@0 | 92 | |
michael@0 | 93 | let ifr = document.createElement('iframe'); |
michael@0 | 94 | ifr.setAttribute('mozbrowser', 'true'); |
michael@0 | 95 | ifr.setAttribute("src", installOrigin + "tests/dom/apps/tests/pkg_install_iframe.html"); |
michael@0 | 96 | |
michael@0 | 97 | ifr.addEventListener("load", function onIFrameLoad() { |
michael@0 | 98 | ifr.removeEventListener("load", onIFrameLoad, false); |
michael@0 | 99 | |
michael@0 | 100 | ifr.contentWindow.postMessage(manifestURL, "*"); |
michael@0 | 101 | }, false); |
michael@0 | 102 | |
michael@0 | 103 | ifr.addEventListener("mozbrowsererror", function onCertError(e) { |
michael@0 | 104 | ifr.removeEventListener("mozbrowsererror", onCertError); |
michael@0 | 105 | |
michael@0 | 106 | ok(false, "mozbrowsererror: " + e.detail.type); |
michael@0 | 107 | domParent.removeChild(ifr); |
michael@0 | 108 | PackagedTestHelper.finish(); |
michael@0 | 109 | }); |
michael@0 | 110 | |
michael@0 | 111 | window.addEventListener("message", function onMessage(event) { |
michael@0 | 112 | window.removeEventListener("message", onMessage); |
michael@0 | 113 | |
michael@0 | 114 | is(event.data, "Application installed", "Application installed"); |
michael@0 | 115 | |
michael@0 | 116 | domParent.removeChild(ifr); |
michael@0 | 117 | }); |
michael@0 | 118 | |
michael@0 | 119 | domParent.appendChild(ifr); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | PackagedTestHelper.setSteps([ |
michael@0 | 123 | function() { |
michael@0 | 124 | SpecialPowers.setAllAppsLaunchable(true); |
michael@0 | 125 | SpecialPowers.addPermission("webapps-manage", true, document); |
michael@0 | 126 | SpecialPowers.addPermission("browser", true, document); |
michael@0 | 127 | SpecialPowers.autoConfirmAppInstall(() => |
michael@0 | 128 | SpecialPowers.pushPrefEnv({set: [["dom.mozBrowserFramesEnabled", true]]}, |
michael@0 | 129 | PackagedTestHelper.next)); |
michael@0 | 130 | }, |
michael@0 | 131 | function() { |
michael@0 | 132 | info("== TEST == Marketplace packaged app from https://marketplace.firefox.com/"); |
michael@0 | 133 | let miniManifestURL = gMarketplaceAppsPath + "marketplace_app.webapp" |
michael@0 | 134 | let expected = { |
michael@0 | 135 | name: "Flashlight (Linterna)", |
michael@0 | 136 | manifestURL: miniManifestURL, |
michael@0 | 137 | installOrigin: gMarketplaceInstallOrigin.slice(0, -1), |
michael@0 | 138 | progress: 0, |
michael@0 | 139 | installState: "installed", |
michael@0 | 140 | downloadAvailable: false, |
michael@0 | 141 | downloading: false, |
michael@0 | 142 | readyToApplyDownload: false, |
michael@0 | 143 | launch_path: "/index.html", |
michael@0 | 144 | version: "2.0", |
michael@0 | 145 | }; |
michael@0 | 146 | checkAppOnInstallSuccess(expected); |
michael@0 | 147 | installApp(gMarketplaceInstallOrigin, miniManifestURL); |
michael@0 | 148 | }, |
michael@0 | 149 | function() { |
michael@0 | 150 | info("== TEST == Marketplace privileged app from https://marketplace.firefox.com/"); |
michael@0 | 151 | let miniManifestURL = gMarketplaceAppsPath + "marketplace_privileged_app.webapp" |
michael@0 | 152 | let expected = { |
michael@0 | 153 | name: "KitchenSink", |
michael@0 | 154 | manifestURL: miniManifestURL, |
michael@0 | 155 | installOrigin: gMarketplaceInstallOrigin.slice(0, -1), |
michael@0 | 156 | progress: 0, |
michael@0 | 157 | installState: "installed", |
michael@0 | 158 | downloadAvailable: false, |
michael@0 | 159 | downloading: false, |
michael@0 | 160 | readyToApplyDownload: false, |
michael@0 | 161 | launch_path: "/index.html", |
michael@0 | 162 | version: "0.2.2", |
michael@0 | 163 | }; |
michael@0 | 164 | checkAppOnInstallSuccess(expected); |
michael@0 | 165 | installApp(gMarketplaceInstallOrigin, miniManifestURL); |
michael@0 | 166 | }, |
michael@0 | 167 | function() { |
michael@0 | 168 | info("== TEST == Marketplace reviewers packaged app from https://marketplace.firefox.com/"); |
michael@0 | 169 | checkAppOnInstallError("INVALID_SIGNATURE"); |
michael@0 | 170 | installApp(gMarketplaceInstallOrigin, gMarketplaceAppsPath + "marketplace_reviewers_app.webapp"); |
michael@0 | 171 | }, |
michael@0 | 172 | function() { |
michael@0 | 173 | info("== TEST == Marketplace packaged app not from https://marketplace.firefox.com/"); |
michael@0 | 174 | checkAppOnInstallError("INSTALL_FROM_DENIED"); |
michael@0 | 175 | installApp(gExternalInstallOrigin, gExternalAppsPath + "marketplace_app.webapp"); |
michael@0 | 176 | }, |
michael@0 | 177 | function() { |
michael@0 | 178 | info("== TEST == Marketplace privileged app not from https://marketplace.firefox.com/"); |
michael@0 | 179 | checkAppOnInstallError("INSTALL_FROM_DENIED"); |
michael@0 | 180 | installApp(gExternalInstallOrigin, gExternalAppsPath + "marketplace_privileged_app.webapp"); |
michael@0 | 181 | }, |
michael@0 | 182 | function() { |
michael@0 | 183 | info("== TEST == Marketplace reviewers packaged app not from https://marketplace.firefox.com/"); |
michael@0 | 184 | checkAppOnInstallError("INVALID_SIGNATURE"); |
michael@0 | 185 | installApp(gExternalInstallOrigin, gExternalAppsPath + "marketplace_reviewers_app.webapp"); |
michael@0 | 186 | }, |
michael@0 | 187 | function() { |
michael@0 | 188 | PackagedTestHelper.finish(); |
michael@0 | 189 | } |
michael@0 | 190 | ]); |
michael@0 | 191 | |
michael@0 | 192 | addLoadEvent(PackagedTestHelper.start); |
michael@0 | 193 | |
michael@0 | 194 | </script> |
michael@0 | 195 | </pre> |
michael@0 | 196 | <div id="container"></div> |
michael@0 | 197 | </body> |
michael@0 | 198 | </html> |