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