summaryrefslogtreecommitdiffstats
path: root/testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html
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 /testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html
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 'testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html')
-rw-r--r--testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html b/testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html
new file mode 100644
index 000000000..569966074
--- /dev/null
+++ b/testing/mochitest/tests/Harness_sanity/test_importInMainProcess.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for SpecialPowers.importInMainProcess</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<div id="content" class="testbody">
+ <script type="text/javascript">
+ SimpleTest.waitForExplicitFinish();
+
+ var failed = false;
+ try {
+ SpecialPowers.importInMainProcess("invalid file for import");
+ } catch (e) {
+ ok(e.toString().indexOf("NS_ERROR_MALFORMED_URI") > -1, "Exception should be for a malformed URI");
+ failed = true;
+ }
+ ok(failed, "An invalid import should throw");
+
+ const testingResource = "resource://testing-common/ImportTesting.jsm";
+ var script = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('importtesting_chromescript.js'));
+
+ script.addMessageListener("ImportTesting:IsModuleLoadedReply", handleFirstReply);
+ script.sendAsyncMessage("ImportTesting:IsModuleLoaded", testingResource);
+
+ function handleFirstReply(aMsg) {
+ ok(!aMsg, "ImportTesting.jsm shouldn't be loaded before we import it");
+
+ try {
+ SpecialPowers.importInMainProcess(testingResource);
+ } catch (e) {
+ ok(false, "Unexpected exception when importing a valid resource: " + e.toString());
+ }
+
+ script.removeMessageListener("ImportTesting:IsModuleLoadedReply", handleFirstReply);
+ script.addMessageListener("ImportTesting:IsModuleLoadedReply", handleSecondReply);
+ script.sendAsyncMessage("ImportTesting:IsModuleLoaded", testingResource);
+ }
+
+ function handleSecondReply(aMsg) {
+ script.removeMessageListener("ImportTesting:IsModuleLoadedReply", handleSecondReply);
+
+ ok(aMsg, "ImportTesting.jsm should be loaded after we import it");
+
+ SimpleTest.finish();
+ }
+
+ </script>
+</div>
+</body>
+</html>