Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | |
michael@0 | 3 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 5 | |
michael@0 | 6 | <?xml-stylesheet type="text/css" href="chrome://global/skin"?> |
michael@0 | 7 | <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> |
michael@0 | 8 | |
michael@0 | 9 | <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | title="Mozilla Bug 741549"> |
michael@0 | 11 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 12 | <script type="application/javascript" src="head.js"/> |
michael@0 | 13 | <!-- test results are displayed in the html:body --> |
michael@0 | 14 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 15 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549" |
michael@0 | 16 | target="_blank">Mozilla Bug 741549</a> |
michael@0 | 17 | </body> |
michael@0 | 18 | |
michael@0 | 19 | <script> |
michael@0 | 20 | |
michael@0 | 21 | var steps = [ |
michael@0 | 22 | noArgs, |
michael@0 | 23 | parseError, |
michael@0 | 24 | invalidManifest, |
michael@0 | 25 | permissionDenied, |
michael@0 | 26 | invalidContent, |
michael@0 | 27 | invalidLaunchPath, |
michael@0 | 28 | invalidLaunchPath2, |
michael@0 | 29 | invalidEntryPoint, |
michael@0 | 30 | invalidLocaleEntryPoint, |
michael@0 | 31 | invalidActivityHref, |
michael@0 | 32 | invalidActivityHref2, |
michael@0 | 33 | invalidMessage, |
michael@0 | 34 | fileURL, |
michael@0 | 35 | originNotAllowed, |
michael@0 | 36 | originAllowed, |
michael@0 | 37 | ]; |
michael@0 | 38 | |
michael@0 | 39 | runAll(steps); |
michael@0 | 40 | |
michael@0 | 41 | function noArgs(next) { |
michael@0 | 42 | try { |
michael@0 | 43 | navigator.mozApps.install(); |
michael@0 | 44 | } catch (e) { |
michael@0 | 45 | is(e.message, "Not enough arguments \[mozIDOMApplicationRegistry.install\]", |
michael@0 | 46 | "install without arguments throws exception"); |
michael@0 | 47 | next(); |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function parseError(next) { |
michael@0 | 52 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/json_syntax_error.webapp"; |
michael@0 | 53 | |
michael@0 | 54 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 55 | is(this.error.name, "MANIFEST_PARSE_ERROR", "manifest with syntax error"); |
michael@0 | 56 | next(); |
michael@0 | 57 | }; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function invalidManifest(next) { |
michael@0 | 61 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/missing_required_field.webapp"; |
michael@0 | 62 | |
michael@0 | 63 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 64 | is(this.error.name, "INVALID_MANIFEST", "manifest missing required field"); |
michael@0 | 65 | next(); |
michael@0 | 66 | }; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function permissionDenied(next) { |
michael@0 | 70 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/no_delegated_install.webapp"; |
michael@0 | 71 | |
michael@0 | 72 | confirmNextInstall(); |
michael@0 | 73 | var request = navigator.mozApps.install(url, null); |
michael@0 | 74 | |
michael@0 | 75 | request.onerror = function onInstallError() { |
michael@0 | 76 | is(this.error.name, "DENIED", "manifest without installs_allowed_from"); |
michael@0 | 77 | next(); |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | request.onsuccess = function onInstall() { |
michael@0 | 81 | todo(false, "manifest without installs_allowed_from fails"); |
michael@0 | 82 | navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() { |
michael@0 | 83 | next(); |
michael@0 | 84 | }; |
michael@0 | 85 | }; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function invalidContent(next) { |
michael@0 | 89 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/bad_content_type.webapp"; |
michael@0 | 90 | |
michael@0 | 91 | var request = navigator.mozApps.install(url, null); |
michael@0 | 92 | |
michael@0 | 93 | request.onerror = function onInstallError() { |
michael@0 | 94 | is(this.error.name, "INVALID_MANIFEST", "manifest with bad content type"); |
michael@0 | 95 | next(); |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | request.onsuccess = function onInstall() { |
michael@0 | 99 | ok(false, "manifest with bad content type should fail"); |
michael@0 | 100 | navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() { |
michael@0 | 101 | next(); |
michael@0 | 102 | }; |
michael@0 | 103 | }; |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | function invalidLaunchPath(next) { |
michael@0 | 107 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_launch_path.webapp"; |
michael@0 | 108 | |
michael@0 | 109 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 110 | is(this.error.name, "INVALID_MANIFEST", "Invalid Manifest"); |
michael@0 | 111 | next(); |
michael@0 | 112 | }; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | function invalidLaunchPath2(next) { |
michael@0 | 116 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_launch_path2.webapp"; |
michael@0 | 117 | |
michael@0 | 118 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 119 | is(this.error.name, "INVALID_MANIFEST", "Invalid Manifest"); |
michael@0 | 120 | next(); |
michael@0 | 121 | }; |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | function invalidEntryPoint(next) { |
michael@0 | 125 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_entry_point.webapp"; |
michael@0 | 126 | |
michael@0 | 127 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 128 | is(this.error.name, "INVALID_MANIFEST", "manifest missing required field"); |
michael@0 | 129 | next(); |
michael@0 | 130 | }; |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | function invalidLocaleEntryPoint(next) { |
michael@0 | 134 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_locale_entry_point.webapp"; |
michael@0 | 135 | |
michael@0 | 136 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 137 | is(this.error.name, "INVALID_MANIFEST", "manifest missing required field"); |
michael@0 | 138 | next(); |
michael@0 | 139 | }; |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | function invalidActivityHref(next) { |
michael@0 | 143 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_activity_href.webapp"; |
michael@0 | 144 | |
michael@0 | 145 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 146 | is(this.error.name, "INVALID_MANIFEST", "Manifest has non-relative URI for activity href"); |
michael@0 | 147 | next(); |
michael@0 | 148 | }; |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | function invalidActivityHref2(next) { |
michael@0 | 152 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_activity_href2.webapp"; |
michael@0 | 153 | |
michael@0 | 154 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 155 | is(this.error.name, "INVALID_MANIFEST", "Manifest has data: URI for activity href"); |
michael@0 | 156 | next(); |
michael@0 | 157 | }; |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | function invalidMessage(next) { |
michael@0 | 161 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/invalid_message.webapp"; |
michael@0 | 162 | |
michael@0 | 163 | navigator.mozApps.install(url, null).onerror = function onInstallError() { |
michael@0 | 164 | is(this.error.name, "INVALID_MANIFEST", "Manifest has absolute message href"); |
michael@0 | 165 | next(); |
michael@0 | 166 | }; |
michael@0 | 167 | } |
michael@0 | 168 | |
michael@0 | 169 | function fileURL(next) { |
michael@0 | 170 | try { |
michael@0 | 171 | var req = navigator.mozApps.install("file:///nonexistent"); |
michael@0 | 172 | req.onsuccess = function() { |
michael@0 | 173 | ok(false, "Unexpected success installing non existent file"); |
michael@0 | 174 | }; |
michael@0 | 175 | req.onerror = function() { |
michael@0 | 176 | is(this.error.name, "INVALID_URL", "Expected INVALID_URL"); |
michael@0 | 177 | }; |
michael@0 | 178 | } catch(ex) { |
michael@0 | 179 | ok(false, "Unexpected exception " + ex.message); |
michael@0 | 180 | } |
michael@0 | 181 | |
michael@0 | 182 | try { |
michael@0 | 183 | req = navigator.mozApps.install("file:///"); |
michael@0 | 184 | req.onsuccess = function() { |
michael@0 | 185 | ok(false, "Unexpected success installing file: URL"); |
michael@0 | 186 | }; |
michael@0 | 187 | req.onerror = function() { |
michael@0 | 188 | is(this.error.name, "INVALID_URL", "Expected INVALID_URL"); |
michael@0 | 189 | }; |
michael@0 | 190 | } catch(ex) { |
michael@0 | 191 | ok(false, "Unexpected exception " + ex.message); |
michael@0 | 192 | } |
michael@0 | 193 | |
michael@0 | 194 | next(); |
michael@0 | 195 | } |
michael@0 | 196 | |
michael@0 | 197 | function originNotAllowed(next) { |
michael@0 | 198 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/installs_allowed_from_example.com.webapp"; |
michael@0 | 199 | |
michael@0 | 200 | var request = navigator.mozApps.install(url, null); |
michael@0 | 201 | |
michael@0 | 202 | request.onerror = function onInstallError() { |
michael@0 | 203 | is(this.error.name, "INSTALL_FROM_DENIED", "origin is not in installs_allowed_from"); |
michael@0 | 204 | next(); |
michael@0 | 205 | }; |
michael@0 | 206 | |
michael@0 | 207 | request.onsuccess = function onInstall() { |
michael@0 | 208 | ok(false, "test should fail because of installs_allowed_from"); |
michael@0 | 209 | navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() { |
michael@0 | 210 | next(); |
michael@0 | 211 | }; |
michael@0 | 212 | }; |
michael@0 | 213 | } |
michael@0 | 214 | |
michael@0 | 215 | function originAllowed(next) { |
michael@0 | 216 | var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/installs_allowed_from_chrome_mochitests.webapp"; |
michael@0 | 217 | |
michael@0 | 218 | confirmNextInstall(); |
michael@0 | 219 | var request = navigator.mozApps.install(url, null); |
michael@0 | 220 | |
michael@0 | 221 | request.onerror = function onInstallError() { |
michael@0 | 222 | ok(false, "installation error: " + this.error.name); |
michael@0 | 223 | next(); |
michael@0 | 224 | }; |
michael@0 | 225 | |
michael@0 | 226 | request.onsuccess = function onInstall() { |
michael@0 | 227 | ok(true, "test origin is in installs_allowed_from"); |
michael@0 | 228 | navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() { |
michael@0 | 229 | next(); |
michael@0 | 230 | }; |
michael@0 | 231 | }; |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | </script> |
michael@0 | 235 | </window> |