summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /chrome/test
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/moz.build10
-rw-r--r--chrome/test/unit/data/test_abi.manifest4
-rw-r--r--chrome/test/unit/data/test_bug292789.manifest4
-rw-r--r--chrome/test/unit/data/test_bug380398.manifest14
-rw-r--r--chrome/test/unit/data/test_bug397073.manifest6
-rw-r--r--chrome/test/unit/data/test_bug399707.manifest11
-rw-r--r--chrome/test/unit/data/test_bug401153.manifest11
-rw-r--r--chrome/test/unit/data/test_bug519468.manifest4
-rw-r--r--chrome/test/unit/data/test_bug564667.xpibin0 -> 569 bytes
-rw-r--r--chrome/test/unit/data/test_bug564667/chrome.manifest16
-rw-r--r--chrome/test/unit/data/test_bug564667/loaded.manifest2
-rw-r--r--chrome/test/unit/data/test_bug848297.manifest4
-rw-r--r--chrome/test/unit/data/test_crlf.manifest3
-rw-r--r--chrome/test/unit/data/test_data_protocol_registration.manifest5
-rw-r--r--chrome/test/unit/data/test_no_remote_registration.manifest32
-rw-r--r--chrome/test/unit/data/test_resolve_uris.manifest5
-rw-r--r--chrome/test/unit/head_crtestutils.js14
-rw-r--r--chrome/test/unit/test_abi.js29
-rw-r--r--chrome/test/unit/test_bug292789.js37
-rw-r--r--chrome/test/unit/test_bug380398.js68
-rw-r--r--chrome/test/unit/test_bug397073.js61
-rw-r--r--chrome/test/unit/test_bug399707.js64
-rw-r--r--chrome/test/unit/test_bug401153.js55
-rw-r--r--chrome/test/unit/test_bug415367.js48
-rw-r--r--chrome/test/unit/test_bug519468.js94
-rw-r--r--chrome/test/unit/test_bug564667.js121
-rw-r--r--chrome/test/unit/test_bug848297.js48
-rw-r--r--chrome/test/unit/test_crlf.js15
-rw-r--r--chrome/test/unit/test_data_protocol_registration.js65
-rw-r--r--chrome/test/unit/test_no_remote_registration.js202
-rw-r--r--chrome/test/unit/test_resolve_uris.js93
-rw-r--r--chrome/test/unit/xpcshell.ini20
-rw-r--r--chrome/test/unit_ipc/test_resolve_uris_ipc.js9
-rw-r--r--chrome/test/unit_ipc/xpcshell.ini10
34 files changed, 1184 insertions, 0 deletions
diff --git a/chrome/test/moz.build b/chrome/test/moz.build
new file mode 100644
index 000000000..ed3bd5bbe
--- /dev/null
+++ b/chrome/test/moz.build
@@ -0,0 +1,10 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+XPCSHELL_TESTS_MANIFESTS += [
+ 'unit/xpcshell.ini',
+ 'unit_ipc/xpcshell.ini',
+]
diff --git a/chrome/test/unit/data/test_abi.manifest b/chrome/test/unit/data/test_abi.manifest
new file mode 100644
index 000000000..6d265fc99
--- /dev/null
+++ b/chrome/test/unit/data/test_abi.manifest
@@ -0,0 +1,4 @@
+category abitest test1 found ABI=XPCShell_noarch-spidermonkey
+category abitest test2 notfound ABI=WINNT_noarch-spidermonkey
+category abitest test3 found ABI!=WINNT_noarch-spidermonkey
+category abitest test4 notfound ABI!=XPCShell_noarch-spidermonkey
diff --git a/chrome/test/unit/data/test_bug292789.manifest b/chrome/test/unit/data/test_bug292789.manifest
new file mode 100644
index 000000000..df67aa15c
--- /dev/null
+++ b/chrome/test/unit/data/test_bug292789.manifest
@@ -0,0 +1,4 @@
+content test1 test/
+content test2 test/ contentaccessible=yes
+content test3 test/ contentaccessible=no
+content test4 test/ contentaccessible
diff --git a/chrome/test/unit/data/test_bug380398.manifest b/chrome/test/unit/data/test_bug380398.manifest
new file mode 100644
index 000000000..a2349c793
--- /dev/null
+++ b/chrome/test/unit/data/test_bug380398.manifest
@@ -0,0 +1,14 @@
+# Success cases
+content test1 test/ appversion=5
+content test2 test/ appversion<6
+content test3 test/ appversion>4
+content test4 test/ appversion>=5
+content test5 test/ appversion<=5
+
+# Failure cases
+content test6 test/ appversion>5
+content test7 test/ appversion<5
+content test8 test/ appversion>
+content test9 test/ appversion<
+content test10 test/ appversion=
+content test11 test/ appversion
diff --git a/chrome/test/unit/data/test_bug397073.manifest b/chrome/test/unit/data/test_bug397073.manifest
new file mode 100644
index 000000000..a219e8c7e
--- /dev/null
+++ b/chrome/test/unit/data/test_bug397073.manifest
@@ -0,0 +1,6 @@
+# Success cases
+content test1 test/ os=xpcshell
+content test2 test/ os=XPCshell
+
+# Failure cases
+content test3 test/ os=FOOshell
diff --git a/chrome/test/unit/data/test_bug399707.manifest b/chrome/test/unit/data/test_bug399707.manifest
new file mode 100644
index 000000000..ac0d97203
--- /dev/null
+++ b/chrome/test/unit/data/test_bug399707.manifest
@@ -0,0 +1,11 @@
+# Success cases
+content test1 test/ application={39885e5f-f6b4-4e2a-87e5-6259ecf79011}
+content test2 test/ application!={d51eecae-eab5-4779-85cb-45f1ec8657c8}
+content test3 test/ application!=
+
+# Failure cases
+content test4 test/ application=
+content test5 test/ application={d51eecae-eab5-4779-85cb-45f1ec8657c8}
+content test6 test/ application!={39885e5f-f6b4-4e2a-87e5-6259ecf79011}
+content test7 test/ appversion=={39885e5f-f6b4-4e2a-87e5-6259ecf79011}
+content test8 test/ application!!{d51eecae-eab5-4779-85cb-45f1ec8657c8}
diff --git a/chrome/test/unit/data/test_bug401153.manifest b/chrome/test/unit/data/test_bug401153.manifest
new file mode 100644
index 000000000..4fcba1bdc
--- /dev/null
+++ b/chrome/test/unit/data/test_bug401153.manifest
@@ -0,0 +1,11 @@
+# Should work
+resource test1 test1/
+
+# Mapping into jar files should work
+resource test3 jar:test3.jar!/resources/
+
+# Invalid line
+resource test4
+
+# Check we made it through the whole manifest
+resource test5 test5/
diff --git a/chrome/test/unit/data/test_bug519468.manifest b/chrome/test/unit/data/test_bug519468.manifest
new file mode 100644
index 000000000..36f0a18f2
--- /dev/null
+++ b/chrome/test/unit/data/test_bug519468.manifest
@@ -0,0 +1,4 @@
+locale testmatchos en-US jar:en-US.jar!/locale/en-US/global/
+locale testmatchos fr-FR jar:en-US.jar!/locale/en-US/global/
+locale testmatchos de-DE jar:en-US.jar!/locale/en-US/global/
+locale testmatchos xx-AA jar:en-US.jar!/locale/en-US/global/
diff --git a/chrome/test/unit/data/test_bug564667.xpi b/chrome/test/unit/data/test_bug564667.xpi
new file mode 100644
index 000000000..be1632d8c
--- /dev/null
+++ b/chrome/test/unit/data/test_bug564667.xpi
Binary files differ
diff --git a/chrome/test/unit/data/test_bug564667/chrome.manifest b/chrome/test/unit/data/test_bug564667/chrome.manifest
new file mode 100644
index 000000000..b35692764
--- /dev/null
+++ b/chrome/test/unit/data/test_bug564667/chrome.manifest
@@ -0,0 +1,16 @@
+# Locally defined URLs
+content test1 test/
+locale test1 en-US test/
+skin test1 test test/
+
+# Test Override
+content testOverride test/
+override chrome://testOverride/content file:///test1/override
+
+
+# Load external manifest
+manifest loaded.manifest
+
+# Failure Cases
+overlay chrome://test1/content/overlay.xul chrome://test1/content/test1.xul
+style chrome://test1/content/style.xul chrome://test1/content/test1.css
diff --git a/chrome/test/unit/data/test_bug564667/loaded.manifest b/chrome/test/unit/data/test_bug564667/loaded.manifest
new file mode 100644
index 000000000..2f231856a
--- /dev/null
+++ b/chrome/test/unit/data/test_bug564667/loaded.manifest
@@ -0,0 +1,2 @@
+content test2 test/
+locale test2 en-US test/
diff --git a/chrome/test/unit/data/test_bug848297.manifest b/chrome/test/unit/data/test_bug848297.manifest
new file mode 100644
index 000000000..d9730a9ce
--- /dev/null
+++ b/chrome/test/unit/data/test_bug848297.manifest
@@ -0,0 +1,4 @@
+locale basepack en-US jar:en-US.jar!/locale/en-US/global/
+locale basepack fr jar:en-US.jar!/locale/en-US/global/
+locale overpack en-US jar:en-US.jar!/locale/en-US/global/
+locale overpack de jar:en-US.jar!/locale/en-US/global/
diff --git a/chrome/test/unit/data/test_crlf.manifest b/chrome/test/unit/data/test_crlf.manifest
new file mode 100644
index 000000000..0f3032112
--- /dev/null
+++ b/chrome/test/unit/data/test_crlf.manifest
@@ -0,0 +1,3 @@
+# Note: the following lines begins/end with a CR
+
+ content test_crlf .
diff --git a/chrome/test/unit/data/test_data_protocol_registration.manifest b/chrome/test/unit/data/test_data_protocol_registration.manifest
new file mode 100644
index 000000000..4effa6ee6
--- /dev/null
+++ b/chrome/test/unit/data/test_data_protocol_registration.manifest
@@ -0,0 +1,5 @@
+# package used only for valid override
+content good-package bar/
+
+# Local resource (should work)
+override chrome://good-package/content/test.xul data:application/vnd.mozilla.xul+xml,
diff --git a/chrome/test/unit/data/test_no_remote_registration.manifest b/chrome/test/unit/data/test_no_remote_registration.manifest
new file mode 100644
index 000000000..b677850ca
--- /dev/null
+++ b/chrome/test/unit/data/test_no_remote_registration.manifest
@@ -0,0 +1,32 @@
+# package used only for valid overlaying and overrides
+content good-package bar/
+
+# UI Resource URIs (should not work)
+content moz-protocol-ui-resource moz-protocol-ui-resource://foo/
+locale moz-protocol-ui-resource en-us moz-protocol-ui-resource://foo/
+skin moz-protocol-ui-resource skin1 moz-protocol-ui-resource://foo/
+override chrome://good-package/content/override-moz-protocol-ui-resource.xul moz-protocol-ui-resource://foo/
+resource moz-protocol-ui-resource moz-protocol-ui-resource://foo/
+
+# Local file URIs (should not work)
+content moz-protocol-local-file moz-protocol-local-file://foo/
+locale moz-protocol-local-file en-us moz-protocol-local-file://foo/
+skin moz-protocol-local-file skin1 moz-protocol-local-file://foo/
+override chrome://good-package/content/override-moz-protocol-local-file.xul moz-protocol-local-file://foo/
+resource moz-protocol-local-file moz-protocol-local-file://foo/
+
+# Loadable by anyone URIs (should not work)
+content moz-protocol-loadable-by-anyone moz-protocol-loadable-by-anyone://foo/
+locale moz-protocol-loadable-by-anyone en-us moz-protocol-loadable-by-anyone://foo/
+skin moz-protocol-loadable-by-anyone skin1 moz-protocol-loadable-by-anyone://foo/
+override chrome://good-package/content/override-moz-protocol-loadable-by-anyone.xul moz-protocol-loadable-by-anyone://foo/
+resource moz-protocol-loadable-by-anyone moz-protocol-loadable-by-anyone://foo/
+
+# Working protocols should be after this point. Failing ones should be before.
+
+# Local resource (should work)
+content moz-protocol-local-resource moz-protocol-local-resource://foo/
+locale moz-protocol-local-resource en-us moz-protocol-local-resource://foo/
+skin moz-protocol-local-resource skin1 moz-protocol-local-resource://foo/
+override chrome://good-package/content/override-moz-protocol-local-resource.xul moz-protocol-local-resource://foo/
+resource moz-protocol-local-resource moz-protocol-local-resource://foo/
diff --git a/chrome/test/unit/data/test_resolve_uris.manifest b/chrome/test/unit/data/test_resolve_uris.manifest
new file mode 100644
index 000000000..43b497e67
--- /dev/null
+++ b/chrome/test/unit/data/test_resolve_uris.manifest
@@ -0,0 +1,5 @@
+resource foo .
+content foo resource://foo/foo-content/
+locale foo foo resource://foo/foo-locale/
+skin foo foo resource://foo/foo-skin/
+override chrome://good-package/content/override-me.xul resource://foo/foo-override/override-me.xul
diff --git a/chrome/test/unit/head_crtestutils.js b/chrome/test/unit/head_crtestutils.js
new file mode 100644
index 000000000..e3be96fd2
--- /dev/null
+++ b/chrome/test/unit/head_crtestutils.js
@@ -0,0 +1,14 @@
+const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
+const XULAPPINFO_CID = Components.ID("{4ba645d3-be6f-40d6-a42a-01b2f40091b8}");
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cr = Components.results;
+
+
+function registerManifests(manifests)
+{
+ var reg = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+ for (var manifest of manifests)
+ reg.autoRegister(manifest);
+}
diff --git a/chrome/test/unit/test_abi.js b/chrome/test/unit/test_abi.js
new file mode 100644
index 000000000..076fd3215
--- /dev/null
+++ b/chrome/test/unit/test_abi.js
@@ -0,0 +1,29 @@
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+updateAppInfo({
+ name: "XPCShell",
+ ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+registerManifests([do_get_file("data/test_abi.manifest")]);
+
+const catman = Components.classes["@mozilla.org/categorymanager;1"].
+ getService(Components.interfaces.nsICategoryManager);
+
+function is_registered(name) {
+ try {
+ var d = catman.getCategoryEntry("abitest", name);
+ return d == "found";
+ }
+ catch (e) {
+ return false;
+ }
+}
+
+function run_test() {
+ do_check_true(is_registered("test1"));
+ do_check_false(is_registered("test2"));
+ do_check_true(is_registered("test3"));
+ do_check_false(is_registered("test4"));
+}
diff --git a/chrome/test/unit/test_bug292789.js b/chrome/test/unit/test_bug292789.js
new file mode 100644
index 000000000..e57c8ac12
--- /dev/null
+++ b/chrome/test/unit/test_bug292789.js
@@ -0,0 +1,37 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+const MANIFESTS = [
+ do_get_file("data/test_bug292789.manifest")
+];
+
+registerManifests(MANIFESTS);
+
+var gIOS;
+var gCR;
+
+function check_accessibility(spec, desired)
+{
+ var uri = gIOS.newURI(spec, null, null);
+ var actual = gCR.allowContentToAccess(uri);
+ do_check_eq(desired, actual);
+}
+
+function run_test()
+{
+ gIOS = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIXULChromeRegistry);
+ gCR.checkForNewChrome();
+
+ check_accessibility("chrome://test1/content/", false);
+ check_accessibility("chrome://test1/content/foo.js", false);
+ check_accessibility("chrome://test2/content/", true);
+ check_accessibility("chrome://test2/content/foo.js", true);
+ check_accessibility("chrome://test3/content/", false);
+ check_accessibility("chrome://test3/content/foo.js", false);
+ check_accessibility("chrome://test4/content/", true);
+}
diff --git a/chrome/test/unit/test_bug380398.js b/chrome/test/unit/test_bug380398.js
new file mode 100644
index 000000000..ce0b6233e
--- /dev/null
+++ b/chrome/test/unit/test_bug380398.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+var MANIFESTS = [
+ do_get_file("data/test_bug380398.manifest")
+];
+
+registerManifests(MANIFESTS);
+
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+updateAppInfo({
+ name: "XPCShell",
+ id: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var target = gIOS.newFileURI(do_get_file("data"));
+target = target.spec + "test/test.xul";
+
+function test_succeeded_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_check_eq(result.spec, target);
+ }
+ catch (ex) {
+ do_throw(namespace);
+ }
+}
+
+function test_failed_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_throw(namespace);
+ }
+ catch (ex) {
+ }
+}
+
+function run_test()
+{
+ test_succeeded_mapping("test1");
+ test_succeeded_mapping("test2");
+ test_succeeded_mapping("test3");
+ test_succeeded_mapping("test4");
+ test_succeeded_mapping("test5");
+ test_failed_mapping("test6");
+ test_failed_mapping("test7");
+ test_failed_mapping("test8");
+ test_failed_mapping("test9");
+ test_failed_mapping("test10");
+ test_failed_mapping("test11");
+}
diff --git a/chrome/test/unit/test_bug397073.js b/chrome/test/unit/test_bug397073.js
new file mode 100644
index 000000000..fb9c6c095
--- /dev/null
+++ b/chrome/test/unit/test_bug397073.js
@@ -0,0 +1,61 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var MANIFESTS = [
+ do_get_file("data/test_bug397073.manifest")
+];
+
+
+registerManifests(MANIFESTS);
+
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+updateAppInfo({
+ name: "XPCShell",
+ ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var target = gIOS.newFileURI(do_get_file("data"));
+target = target.spec + "test/test.xul";
+
+function test_succeeded_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_check_eq(result.spec, target);
+ }
+ catch (ex) {
+ do_throw(namespace);
+ }
+}
+
+function test_failed_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_throw(namespace);
+ }
+ catch (ex) {
+ }
+}
+
+function run_test()
+{
+ test_succeeded_mapping("test1");
+ test_succeeded_mapping("test2");
+
+ test_failed_mapping("test3");
+}
diff --git a/chrome/test/unit/test_bug399707.js b/chrome/test/unit/test_bug399707.js
new file mode 100644
index 000000000..05273550c
--- /dev/null
+++ b/chrome/test/unit/test_bug399707.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var MANIFESTS = [
+ do_get_file("data/test_bug399707.manifest")
+];
+
+registerManifests(MANIFESTS);
+
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+updateAppInfo({
+ name: "XPCShell",
+ ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var target = gIOS.newFileURI(do_get_file("data"));
+target = target.spec + "test/test.xul";
+
+function test_succeeded_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_check_eq(result.spec, target);
+ }
+ catch (ex) {
+ do_throw(namespace);
+ }
+}
+
+function test_failed_mapping(namespace)
+{
+ var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul",
+ null, null);
+ try {
+ var result = chromeReg.convertChromeURL(uri);
+ do_throw(namespace);
+ }
+ catch (ex) {
+ }
+}
+
+function run_test()
+{
+ test_succeeded_mapping("test1");
+ test_succeeded_mapping("test2");
+ test_succeeded_mapping("test3");
+ test_failed_mapping("test4");
+ test_failed_mapping("test5");
+ test_failed_mapping("test6");
+ test_failed_mapping("test7");
+ test_failed_mapping("test8");
+}
diff --git a/chrome/test/unit/test_bug401153.js b/chrome/test/unit/test_bug401153.js
new file mode 100644
index 000000000..3317d8b1e
--- /dev/null
+++ b/chrome/test/unit/test_bug401153.js
@@ -0,0 +1,55 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var MANIFESTS = [
+ do_get_file("data/test_bug401153.manifest")
+];
+
+registerManifests(MANIFESTS);
+
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+updateAppInfo({
+ name: "XPCShell",
+ ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var rph = gIOS.getProtocolHandler("resource")
+ .QueryInterface(Ci.nsIResProtocolHandler);
+
+function test_succeeded_mapping(namespace, target)
+{
+ try {
+ do_check_true(rph.hasSubstitution(namespace));
+ var uri = gIOS.newURI("resource://" + namespace, null, null);
+ dump("### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n");
+ do_check_eq(rph.resolveURI(uri), target);
+ }
+ catch (ex) {
+ dump(ex + "\n");
+ do_throw(namespace);
+ }
+}
+
+function test_failed_mapping(namespace)
+{
+ do_check_false(rph.hasSubstitution(namespace));
+}
+
+function run_test()
+{
+ var data = gIOS.newFileURI(do_get_file("data")).spec;
+ test_succeeded_mapping("test1", data + "test1/");
+ test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
+ test_failed_mapping("test4");
+ test_succeeded_mapping("test5", data + "test5/");
+}
diff --git a/chrome/test/unit/test_bug415367.js b/chrome/test/unit/test_bug415367.js
new file mode 100644
index 000000000..6d02223c0
--- /dev/null
+++ b/chrome/test/unit/test_bug415367.js
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+
+function test_uri(obj)
+{
+ var uri = null;
+ var failed = false;
+ var message = "";
+ try {
+ uri = gIOS.newURI(obj.uri, null, null);
+ if (!obj.result) {
+ failed = true;
+ message = obj.uri + " should not be accepted as a valid URI";
+ }
+ }
+ catch (ex) {
+ if (obj.result) {
+ failed = true;
+ message = obj.uri + " should be accepted as a valid URI";
+ }
+ }
+ if (failed)
+ do_throw(message);
+ if (obj.result) {
+ do_check_true(uri != null);
+ do_check_eq(uri.spec, obj.uri);
+ }
+}
+
+function run_test()
+{
+ var tests = [
+ {uri: "chrome://blah/content/blah.xul", result: true},
+ {uri: "chrome://blah/content/:/blah/blah.xul", result: false},
+ {uri: "chrome://blah/content/%252e./blah/blah.xul", result: false},
+ {uri: "chrome://blah/content/%252e%252e/blah/blah.xul", result: false},
+ {uri: "chrome://blah/content/blah.xul?param=%252e./blah/", result: true},
+ {uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true},
+ {uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/", result: true},
+ ];
+ for (var i = 0; i < tests.length; ++ i)
+ test_uri(tests[i]);
+}
diff --git a/chrome/test/unit/test_bug519468.js b/chrome/test/unit/test_bug519468.js
new file mode 100644
index 000000000..69c5c8622
--- /dev/null
+++ b/chrome/test/unit/test_bug519468.js
@@ -0,0 +1,94 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var MANIFESTS = [
+ do_get_file("data/test_bug519468.manifest")
+];
+
+Components.utils.import("resource://testing-common/MockRegistrar.jsm");
+// Stub in the locale service so we can control what gets returned as the OS locale setting
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+var stubOSLocale = null;
+
+StubLocaleService = {
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsILocaleService, Ci.nsISupports]),
+
+ getLocaleComponentForUserAgent: function SLS_getLocaleComponentForUserAgent()
+ {
+ return stubOSLocale;
+ }
+}
+
+MockRegistrar.register("@mozilla.org/intl/nslocaleservice;1", StubLocaleService);
+
+// Now fire up the test
+do_test_pending()
+registerManifests(MANIFESTS);
+
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIXULChromeRegistry)
+ .QueryInterface(Ci.nsIToolkitChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var prefService = Cc["@mozilla.org/preferences-service;1"]
+ .getService(Ci.nsIPrefService)
+ .QueryInterface(Ci.nsIPrefBranch);
+var os = Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService);
+
+var testsLocale = [
+ // These tests cover when the OS local is included in our manifest
+ {matchOS: false, selected: "en-US", osLocale: "xx-AA", locale: "en-US"},
+ {matchOS: true, selected: "en-US", osLocale: "xx-AA", locale: "xx-AA"},
+ {matchOS: false, selected: "fr-FR", osLocale: "xx-AA", locale: "fr-FR"},
+ {matchOS: true, selected: "fr-FR", osLocale: "xx-AA", locale: "xx-AA"},
+ {matchOS: false, selected: "de-DE", osLocale: "xx-AA", locale: "de-DE"},
+ {matchOS: true, selected: "de-DE", osLocale: "xx-AA", locale: "xx-AA"},
+ // these tests cover the case where the OS locale is not available in our manifest, but the
+ // base language is (ie, substitute xx-AA which we have for xx-BB which we don't)
+ {matchOS: false, selected: "en-US", osLocale: "xx-BB", locale: "en-US"},
+ {matchOS: true, selected: "en-US", osLocale: "xx-BB", locale: "xx-AA"},
+ {matchOS: false, selected: "fr-FR", osLocale: "xx-BB", locale: "fr-FR"},
+ {matchOS: true, selected: "fr-FR", osLocale: "xx-BB", locale: "xx-AA"},
+ // These tests cover where the language is not available
+ {matchOS: false, selected: "en-US", osLocale: "xy-BB", locale: "en-US"},
+ {matchOS: true, selected: "en-US", osLocale: "xy-BB", locale: "en-US"},
+ {matchOS: false, selected: "fr-FR", osLocale: "xy-BB", locale: "fr-FR"},
+ {matchOS: true, selected: "fr-FR", osLocale: "xy-BB", locale: "en-US"},
+];
+
+var observedLocale = null;
+
+function test_locale(aTest) {
+ observedLocale = null;
+
+ stubOSLocale = aTest.osLocale;
+ prefService.setBoolPref("intl.locale.matchOS", aTest.matchOS);
+ prefService.setCharPref("general.useragent.locale", aTest.selected);
+
+ chromeReg.reloadChrome();
+
+ do_check_eq(observedLocale, aTest.locale);
+}
+
+// Callback function for observing locale change. May be called more than once
+// per test iteration.
+function checkValidity() {
+ observedLocale = chromeReg.getSelectedLocale("testmatchos");
+ dump("checkValidity called back with locale = " + observedLocale + "\n");
+}
+
+function run_test() {
+ os.addObserver(checkValidity, "selected-locale-has-changed", false);
+
+ for (let count = 0 ; count < testsLocale.length ; count++) {
+ dump("count = " + count + " " + testsLocale[count].toSource() + "\n");
+ test_locale(testsLocale[count]);
+ }
+
+ os.removeObserver(checkValidity, "selected-locale-has-changed");
+ do_test_finished();
+}
diff --git a/chrome/test/unit/test_bug564667.js b/chrome/test/unit/test_bug564667.js
new file mode 100644
index 000000000..5f5e9940d
--- /dev/null
+++ b/chrome/test/unit/test_bug564667.js
@@ -0,0 +1,121 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+const UNPACKAGED_ADDON = do_get_file("data/test_bug564667");
+const PACKAGED_ADDON = do_get_file("data/test_bug564667.xpi");
+
+var gIOS = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+var gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry).
+ QueryInterface(Ci.nsIXULOverlayProvider);
+
+/*
+ * Checks that a mapping was added
+ */
+function test_mapping(chromeURL, target) {
+ var uri = gIOS.newURI(chromeURL, null, null);
+
+ try {
+ var result = gCR.convertChromeURL(uri);
+ do_check_eq(result.spec, target);
+ }
+ catch (ex) {
+ do_throw(chromeURL + " not Registered");
+ }
+}
+
+/*
+ * Checks that a mapping was removed
+ */
+function test_removed_mapping(chromeURL, target) {
+ var uri = gIOS.newURI(chromeURL, null, null);
+ try {
+ var result = gCR.convertChromeURL(uri);
+ do_throw(chromeURL + " not removed");
+ }
+ catch (ex) {
+ // This should throw
+ }
+}
+
+/*
+ * Checks if any overlay was added after loading
+ * the manifest files
+ *
+ * @param type The type of overlay: overlay|style
+ */
+function test_no_overlays(chromeURL, target, type) {
+ var type = type || "overlay";
+ var uri = gIOS.newURI(chromeURL, null, null);
+ var present = false, elem;
+
+ var overlays = (type == "overlay") ?
+ gCR.getXULOverlays(uri) : gCR.getStyleOverlays(uri);
+
+ // We shouldn't be allowed to register overlays nor styles
+ if (overlays.hasMoreElements()) {
+ if (type == "styles")
+ do_throw("Style Registered: " + chromeURL);
+ else
+ do_throw("Overlay Registered: " + chromeURL);
+ }
+}
+
+function testManifest(manifestPath, baseURI) {
+
+ // ------------------ Add manifest file ------------------------
+ Components.manager.addBootstrappedManifestLocation(manifestPath);
+
+ // Test Adding Content URL
+ test_mapping("chrome://test1/content", baseURI + "test/test1.xul");
+
+ // Test Adding Locale URL
+ test_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
+
+ // Test Adding Skin URL
+ test_mapping("chrome://test1/skin", baseURI + "test/test1.css");
+
+ // Test Adding Manifest URL
+ test_mapping("chrome://test2/content", baseURI + "test/test2.xul");
+ test_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
+
+ // Test Adding Override
+ test_mapping("chrome://testOverride/content", 'file:///test1/override')
+
+ // Test Not-Adding Overlays
+ test_no_overlays("chrome://test1/content/overlay.xul",
+ "chrome://test1/content/test1.xul");
+
+ // Test Not-Adding Styles
+ test_no_overlays("chrome://test1/content/style.xul",
+ "chrome://test1/content/test1.css", "styles");
+
+
+ // ------------------ Remove manifest file ------------------------
+ Components.manager.removeBootstrappedManifestLocation(manifestPath);
+
+ // Test Removing Content URL
+ test_removed_mapping("chrome://test1/content", baseURI + "test/test1.xul");
+
+ // Test Removing Content URL
+ test_removed_mapping("chrome://test1/locale", baseURI + "test/test1.dtd");
+
+ // Test Removing Skin URL
+ test_removed_mapping("chrome://test1/skin", baseURI + "test/test1.css");
+
+ // Test Removing Manifest URL
+ test_removed_mapping("chrome://test2/content", baseURI + "test/test2.xul");
+ test_removed_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");
+}
+
+function run_test() {
+ // Test an unpackaged addon
+ testManifest(UNPACKAGED_ADDON, gIOS.newFileURI(UNPACKAGED_ADDON).spec);
+
+ // Test a packaged addon
+ testManifest(PACKAGED_ADDON, "jar:" + gIOS.newFileURI(PACKAGED_ADDON).spec + "!/");
+}
diff --git a/chrome/test/unit/test_bug848297.js b/chrome/test/unit/test_bug848297.js
new file mode 100644
index 000000000..0875370f7
--- /dev/null
+++ b/chrome/test/unit/test_bug848297.js
@@ -0,0 +1,48 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+var MANIFESTS = [
+ do_get_file("data/test_bug848297.manifest")
+];
+
+// Stub in the locale service so we can control what gets returned as the OS locale setting
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+registerManifests(MANIFESTS);
+
+var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIXULChromeRegistry)
+ .QueryInterface(Ci.nsIToolkitChromeRegistry);
+chromeReg.checkForNewChrome();
+
+var prefService = Cc["@mozilla.org/preferences-service;1"]
+ .getService(Ci.nsIPrefService)
+ .QueryInterface(Ci.nsIPrefBranch);
+
+function enum_to_array(strings) {
+ let rv = [];
+ while (strings.hasMore()) {
+ rv.push(strings.getNext());
+ }
+ rv.sort();
+ return rv;
+}
+
+function run_test() {
+
+ // without override
+ prefService.setCharPref("general.useragent.locale", "de");
+ do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US");
+ do_check_eq(chromeReg.getSelectedLocale("overpack"), "de");
+ do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
+ ['en-US', 'fr']);
+
+ // with override
+ prefService.setCharPref("chrome.override_package.basepack", "overpack");
+ do_check_eq(chromeReg.getSelectedLocale("basepack"), "de");
+ do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
+ ['de', 'en-US']);
+
+}
diff --git a/chrome/test/unit/test_crlf.js b/chrome/test/unit/test_crlf.js
new file mode 100644
index 000000000..b577c49a9
--- /dev/null
+++ b/chrome/test/unit/test_crlf.js
@@ -0,0 +1,15 @@
+registerManifests([do_get_file("data/test_crlf.manifest")]);
+
+function run_test()
+{
+ let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry);
+
+ let ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ let sourceURI = ios.newURI("chrome://test_crlf/content/", null, null);
+ // this throws for packages that are not registered
+ let file = cr.convertChromeURL(sourceURI).QueryInterface(Ci.nsIFileURL).file;
+
+ do_check_true(file.equals(do_get_file("data/test_crlf.xul", true)));
+}
diff --git a/chrome/test/unit/test_data_protocol_registration.js b/chrome/test/unit/test_data_protocol_registration.js
new file mode 100644
index 000000000..71138bd92
--- /dev/null
+++ b/chrome/test/unit/test_data_protocol_registration.js
@@ -0,0 +1,65 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
+ * vim: sw=2 ts=2 sts=2 tw=78 expandtab :
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var manifests = [
+ do_get_file("data/test_data_protocol_registration.manifest"),
+];
+registerManifests(manifests);
+
+var XULAppInfoFactory = {
+ // These two are used when we register all our factories (and unregister)
+ CID: XULAPPINFO_CID,
+ scheme: "XULAppInfo",
+ contractID: XULAPPINFO_CONTRACTID,
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return XULAppInfo.QueryInterface(iid);
+ }
+};
+
+function run_test()
+{
+ // Add our XULAppInfo factory
+ let factories = [XULAppInfoFactory];
+
+ // Register our factories
+ for (let i = 0; i < factories.length; i++) {
+ let factory = factories[i];
+ Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
+ .registerFactory(factory.CID, "test-" + factory.scheme,
+ factory.contractID, factory);
+ }
+
+ // Check for new chrome
+ let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry);
+ cr.checkForNewChrome();
+
+ // Check that our override worked
+ let expectedURI = "data:application/vnd.mozilla.xul+xml,";
+ let sourceURI = "chrome://good-package/content/test.xul";
+ try {
+ let ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ sourceURI = ios.newURI(sourceURI, null, null);
+ // this throws for packages that are not registered
+ let uri = cr.convertChromeURL(sourceURI).spec;
+
+ do_check_eq(expectedURI, uri);
+ }
+ catch (e) {
+ dump(e + "\n");
+ do_throw("Should have registered our URI!");
+ }
+
+ // Unregister our factories so we do not leak
+ for (let i = 0; i < factories.length; i++) {
+ let factory = factories[i];
+ Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
+ .unregisterFactory(factory.CID, factory);
+ }
+}
diff --git a/chrome/test/unit/test_no_remote_registration.js b/chrome/test/unit/test_no_remote_registration.js
new file mode 100644
index 000000000..281a79dd3
--- /dev/null
+++ b/chrome/test/unit/test_no_remote_registration.js
@@ -0,0 +1,202 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
+ * vim: sw=2 ts=2 sts=2 tw=78 expandtab :
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var manifests = [
+ do_get_file("data/test_no_remote_registration.manifest"),
+];
+registerManifests(manifests);
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+Components.utils.import("resource://testing-common/AppInfo.jsm", this);
+var XULAppInfo = newAppInfo({
+ name: "XPCShell",
+ ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
+ version: "5",
+ platformVersion: "1.9",
+});
+
+var XULAppInfoFactory = {
+ // These two are used when we register all our factories (and unregister)
+ CID: Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}"),
+ scheme: "XULAppInfo",
+ contractID: "@mozilla.org/xre/app-info;1",
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return XULAppInfo.QueryInterface(iid);
+ }
+};
+
+function ProtocolHandler(aScheme, aFlags)
+{
+ this.scheme = aScheme;
+ this.protocolFlags = aFlags;
+ this.contractID = "@mozilla.org/network/protocol;1?name=" + aScheme;
+}
+
+ProtocolHandler.prototype =
+{
+ defaultPort: -1,
+ allowPort: () => false,
+ newURI: function(aSpec, aCharset, aBaseURI)
+ {
+ let uri = Cc["@mozilla.org/network/standard-url;1"].
+ createInstance(Ci.nsIURI);
+ uri.spec = aSpec;
+ if (!uri.scheme) {
+ // We got a partial uri, so let's resolve it with the base one
+ uri.spec = aBaseURI.resolve(aSpec);
+ }
+ return uri;
+ },
+ newChannel2: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED },
+ newChannel: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED },
+ QueryInterface: XPCOMUtils.generateQI([
+ Ci.nsIProtocolHandler
+ ])
+};
+
+var testProtocols = [
+ // It doesn't matter if it has this flag - the only flag we accept is
+ // URI_IS_LOCAL_RESOURCE.
+ {scheme: "moz-protocol-ui-resource",
+ flags: Ci.nsIProtocolHandler.URI_IS_UI_RESOURCE,
+ CID: Components.ID("{d6dedc93-558f-44fe-90f4-3b4bba8a0b14}"),
+ shouldRegister: false
+ },
+ // It doesn't matter if it has this flag - the only flag we accept is
+ // URI_IS_LOCAL_RESOURCE.
+ {scheme: "moz-protocol-local-file",
+ flags: Ci.nsIProtocolHandler.URI_IS_LOCAL_FILE,
+ CID: Components.ID("{ee30d594-0a2d-4f47-89cc-d4cde320ab69}"),
+ shouldRegister: false
+ },
+ // This clearly is non-local
+ {scheme: "moz-protocol-loadable-by-anyone",
+ flags: Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,
+ CID: Components.ID("{c3735f23-3b0c-4a33-bfa0-79436dcd40b2}"),
+ shouldRegister: false
+ },
+ // This should always be last (unless we add more flags that are OK)
+ {scheme: "moz-protocol-local-resource",
+ flags: Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE,
+ CID: Components.ID("{b79e977c-f840-469a-b413-0125cc1b62a5}"),
+ shouldRegister: true
+ },
+];
+function run_test()
+{
+ // Create factories
+ let factories = [];
+ for (let i = 0; i < testProtocols.length; i++) {
+ factories[i] = {
+ scheme: testProtocols[i].scheme,
+ flags: testProtocols[i].flags,
+ CID: testProtocols[i].CID,
+ contractID: "@mozilla.org/network/protocol;1?name=" + testProtocols[i].scheme,
+ createInstance: function(aOuter, aIID)
+ {
+ if (aOuter != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ let handler = new ProtocolHandler(this.scheme, this.flags, this.CID);
+ return handler.QueryInterface(aIID);
+ }
+ };
+ }
+ // Add our XULAppInfo factory
+ factories.push(XULAppInfoFactory);
+
+ // Register our factories
+ for (let i = 0; i < factories.length; i++) {
+ let factory = factories[i];
+ Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
+ .registerFactory(factory.CID, "test-" + factory.scheme,
+ factory.contractID, factory);
+ }
+
+ // Check for new chrome
+ let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry);
+ cr.checkForNewChrome();
+
+ // See if our various things were able to register
+ let registrationTypes = [
+ "content",
+ "locale",
+ "skin",
+ "override",
+ "resource",
+ ];
+ for (let i = 0; i < testProtocols.length; i++) {
+ let protocol = testProtocols[i];
+ for (let j = 0; j < registrationTypes.length; j++) {
+ let type = registrationTypes[j];
+ dump("Testing protocol '" + protocol.scheme + "' with type '" + type +
+ "'\n");
+ let expectedURI = protocol.scheme + "://foo/";
+ let sourceURI = "chrome://" + protocol.scheme + "/" + type + "/";
+ switch (type) {
+ case "content":
+ expectedURI += protocol.scheme + ".xul";
+ break;
+ case "locale":
+ expectedURI += protocol.scheme + ".dtd";
+ break;
+ case "skin":
+ expectedURI += protocol.scheme + ".css";
+ break;
+ case "override":
+ sourceURI = "chrome://good-package/content/override-" +
+ protocol.scheme + ".xul";
+ break;
+ case "resource":
+ sourceURI = "resource://" + protocol.scheme + "/";
+ break;
+ };
+ try {
+ let ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+ sourceURI = ios.newURI(sourceURI, null, null);
+ let uri;
+ if (type == "resource") {
+ // resources go about a slightly different way than everything else
+ let rph = ios.getProtocolHandler("resource").
+ QueryInterface(Ci.nsIResProtocolHandler);
+ // this throws for packages that are not registered
+ uri = rph.resolveURI(sourceURI);
+ }
+ else {
+ // this throws for packages that are not registered
+ uri = cr.convertChromeURL(sourceURI).spec;
+ }
+
+ if (protocol.shouldRegister) {
+ do_check_eq(expectedURI, uri);
+ }
+ else {
+ // Overrides will not throw, so we'll get to here. We want to make
+ // sure that the two strings are not the same in this situation.
+ do_check_neq(expectedURI, uri);
+ }
+ }
+ catch (e) {
+ if (protocol.shouldRegister) {
+ dump(e + "\n");
+ do_throw("Should have registered our URI for protocol " +
+ protocol.scheme);
+ }
+ }
+ }
+ }
+
+ // Unregister our factories so we do not leak
+ for (let i = 0; i < factories.length; i++) {
+ let factory = factories[i];
+ Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
+ .unregisterFactory(factory.CID, factory);
+ }
+}
diff --git a/chrome/test/unit/test_resolve_uris.js b/chrome/test/unit/test_resolve_uris.js
new file mode 100644
index 000000000..30ae9bc26
--- /dev/null
+++ b/chrome/test/unit/test_resolve_uris.js
@@ -0,0 +1,93 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// head_crtestutils.js doesn't get included in the child by default
+if (typeof registerManifests === "undefined") {
+ load("../unit/head_crtestutils.js");
+}
+
+var manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
+
+var manifests = [ manifestFile ];
+registerManifests(manifests);
+
+var ios = Cc["@mozilla.org/network/io-service;1"].
+ getService(Ci.nsIIOService);
+
+function do_run_test()
+{
+ let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Ci.nsIChromeRegistry);
+
+ // If we don't have libxul or e10s then we don't have process separation, so
+ // we don't need to worry about checking for new chrome.
+ var appInfo = Cc["@mozilla.org/xre/app-info;1"];
+ if (!appInfo ||
+ (appInfo.getService(Ci.nsIXULRuntime).processType ==
+ Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)) {
+ cr.checkForNewChrome();
+ }
+
+ // See if our various things were able to register
+ let registrationTypes = [
+ "content",
+ "locale",
+ "skin",
+ "override",
+ "resource",
+ ];
+
+ for (let j = 0; j < registrationTypes.length; j++) {
+ let type = registrationTypes[j];
+ dump("Testing type '" + type + "'\n");
+ let expectedURI = "resource://foo/foo-" + type + "/";
+ let sourceURI = "chrome://foo/" + type + "/";
+ switch (type) {
+ case "content":
+ expectedURI += "foo.xul";
+ break;
+ case "locale":
+ expectedURI += "foo.dtd";
+ break;
+ case "skin":
+ expectedURI += "foo.css";
+ break;
+ case "override":
+ sourceURI = "chrome://good-package/content/override-me.xul";
+ expectedURI += "override-me.xul";
+ break;
+ case "resource":
+ expectedURI = ios.newFileURI(manifestFile.parent).spec;
+ sourceURI = "resource://foo/";
+ break;
+ };
+ try {
+ sourceURI = ios.newURI(sourceURI, null, null);
+ let uri;
+ if (type == "resource") {
+ // resources go about a slightly different way than everything else
+ let rph = ios.getProtocolHandler("resource").
+ QueryInterface(Ci.nsIResProtocolHandler);
+ uri = rph.resolveURI(sourceURI);
+ }
+ else {
+ uri = cr.convertChromeURL(sourceURI).spec;
+ }
+
+ do_check_eq(expectedURI, uri);
+ }
+ catch (e) {
+ dump(e + "\n");
+ do_throw("Should have registered a handler for type '" +
+ type + "'\n");
+ }
+ }
+}
+
+if (typeof run_test === "undefined") {
+ run_test = function() {
+ do_run_test();
+ };
+}
diff --git a/chrome/test/unit/xpcshell.ini b/chrome/test/unit/xpcshell.ini
new file mode 100644
index 000000000..3b9f84547
--- /dev/null
+++ b/chrome/test/unit/xpcshell.ini
@@ -0,0 +1,20 @@
+[DEFAULT]
+head = head_crtestutils.js
+tail =
+support-files = data/**
+
+[test_abi.js]
+[test_bug292789.js]
+[test_bug380398.js]
+[test_bug397073.js]
+[test_bug399707.js]
+[test_bug401153.js]
+[test_bug415367.js]
+[test_bug519468.js]
+[test_bug564667.js]
+tags = addons
+[test_bug848297.js]
+[test_crlf.js]
+[test_data_protocol_registration.js]
+[test_no_remote_registration.js]
+[test_resolve_uris.js]
diff --git a/chrome/test/unit_ipc/test_resolve_uris_ipc.js b/chrome/test/unit_ipc/test_resolve_uris_ipc.js
new file mode 100644
index 000000000..8babc23fd
--- /dev/null
+++ b/chrome/test/unit_ipc/test_resolve_uris_ipc.js
@@ -0,0 +1,9 @@
+//
+// Run test script in content process instead of chrome (xpcshell's default)
+//
+
+function run_test() {
+ load("../unit/test_resolve_uris.js");
+ do_run_test();
+ run_test_in_child("../unit/test_resolve_uris.js");
+}
diff --git a/chrome/test/unit_ipc/xpcshell.ini b/chrome/test/unit_ipc/xpcshell.ini
new file mode 100644
index 000000000..1633bf995
--- /dev/null
+++ b/chrome/test/unit_ipc/xpcshell.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+head =
+tail =
+skip-if = toolkit == 'android'
+support-files =
+ !/chrome/test/unit/data/**
+ !/chrome/test/unit/test_resolve_uris.js
+ !/chrome/test/unit/head_crtestutils.js
+
+[test_resolve_uris_ipc.js]