diff options
author | Moonchild <mcwerewolf@wolfbeast.com> | 2019-03-13 07:49:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-13 07:49:07 +0100 |
commit | bf0413359245579e9509146d42cd5547e35da695 (patch) | |
tree | 8218d4f60d9eccacbf42df8cb88094a082d401b4 /toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html | |
parent | 51b821b3fdc5a7eab2369cb6a6680598a6264b08 (diff) | |
parent | 709bc24e9110eba12f94cfcb8db00a8338ac4098 (diff) | |
download | UXP-bf0413359245579e9509146d42cd5547e35da695.tar UXP-bf0413359245579e9509146d42cd5547e35da695.tar.gz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.lz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.xz UXP-bf0413359245579e9509146d42cd5547e35da695.zip |
Merge pull request #998 from MoonchildProductions/master
Merge master into Sync-weave
Diffstat (limited to 'toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html')
-rw-r--r-- | toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html deleted file mode 100644 index f3414901d..000000000 --- a/toolkit/components/webextensions/test/mochitest/test_ext_contentscript_exporthelpers.html +++ /dev/null @@ -1,95 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for content script</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script> - <script type="text/javascript" src="head.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> -</head> -<body> - -<script> -"use strict"; - -add_task(function* test_contentscript_exportHelpers() { - function contentScript() { - browser.test.assertTrue(typeof cloneInto === "function"); - browser.test.assertTrue(typeof createObjectIn === "function"); - browser.test.assertTrue(typeof exportFunction === "function"); - - /* globals exportFunction, precisePi, reportPi */ - let value = 3.14; - exportFunction(() => value, window, {defineAs: "precisePi"}); - - browser.test.assertEq("undefined", typeof precisePi, - "exportFunction should export to the page's scope only"); - - browser.test.assertEq("undefined", typeof window.precisePi, - "exportFunction should export to the page's scope only"); - - let results = []; - exportFunction(pi => results.push(pi), window, {defineAs: "reportPi"}); - - let s = document.createElement("script"); - s.textContent = `(${function() { - let result1 = "unknown 1"; - let result2 = "unknown 2"; - try { - result1 = precisePi(); - } catch (e) { - result1 = "err:" + e; - } - try { - result2 = window.precisePi(); - } catch (e) { - result2 = "err:" + e; - } - reportPi(result1); - reportPi(result2); - }})();`; - - document.documentElement.appendChild(s); - // Inline script ought to run synchronously. - - browser.test.assertEq(3.14, results[0], - "exportFunction on window should define a global function"); - browser.test.assertEq(3.14, results[1], - "exportFunction on window should export a property to window."); - - browser.test.assertEq(2, results.length, - "Expecting the number of results to match the number of method calls"); - - browser.test.notifyPass("export helper test completed"); - } - - let extensionData = { - manifest: { - content_scripts: [{ - js: ["contentscript.js"], - matches: ["http://mochi.test/*/file_sample.html"], - run_at: "document_start", - }], - }, - - files: { - "contentscript.js": contentScript, - }, - }; - - let extension = ExtensionTestUtils.loadExtension(extensionData); - - yield extension.startup(); - - let win = window.open("file_sample.html"); - - yield extension.awaitFinish("export helper test completed"); - win.close(); - - yield extension.unload(); -}); -</script> - -</body> -</html> |