Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / chrome / test_chrometoSource.xhtml
blob6710a59289249e9a909bd21f290bdc62b04123fa
1 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
4 type="text/css"?>
5 <window title="Mozilla Bug 761723"
6 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
7 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <!-- test results are displayed in the html:body -->
10 <body xmlns="http://www.w3.org/1999/xhtml">
11 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=761723" target="_blank">Mozilla Bug 761723</a>
12 </body>
14 <!-- test code goes here -->
15 <script type="application/javascript" src="outoflinexulscript.js"></script>
16 <script type="application/javascript"><![CDATA[
17 const {NetUtil} = ChromeUtils.importESModule(
18 "resource://gre/modules/NetUtil.sys.mjs"
20 let base = /.*\//.exec(window.location.href)[0];
21 const {checkFromJSM} = ChromeUtils.import(base + "file_expandosharing.jsm");
23 function inlinefunction() {
24 return 42;
27 var src;
28 src = inlinefunction.toSource();
29 isnot(src.indexOf("return 42"), -1, "inline XUL script should have source");
30 is(src.charAt(src.length - 1), "}", "inline XUL source should end with '}'");
31 src = outoflinefunction.toSource();
32 isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source")
33 is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'");
34 src = checkFromJSM.toSource();
35 isnot(src.indexOf("catch"), -1, "JSM should have source");
36 var ns = {};
37 Services.scriptloader.loadSubScript(base + "file_expandosharing.jsm", ns);
38 src = ns.checkFromJSM.toSource();
39 isnot(src.indexOf("catch"), -1, "subscript should have source");
41 var reg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
42 var resolvedBase = reg.convertChromeURL(NetUtil.newURI(base)).spec;
44 ns = {
45 base,
47 Services.scriptloader.loadSubScript(resolvedBase + "subscript.js", ns);
48 src = ns.checkFromJSM.toSource();
49 isnot(src.indexOf("catch"), -1, "subscript of a subscript should have source");
51 ns = {};
52 Services.scriptloader.loadSubScript(resolvedBase + "utf8_subscript.js", ns);
53 src = ns.f.toSource();
54 isnot(src.indexOf("return 42;"), -1, "encoded subscript should have correct source");
56 ns = {};
57 Services.scriptloader.loadSubScriptWithOptions(resolvedBase + "utf8_subscript.js",
58 {target: ns, ignoreCache: true});
59 src = ns.f.toSource();
60 isnot(src.indexOf("return 42;"), -1, "encoded subscript should have correct source");
62 ns = {};
63 let b = new Blob([
64 "var Exported = 17;"
65 ]);
66 var blobUrl = URL.createObjectURL(b);
67 Services.scriptloader.loadSubScript(blobUrl, ns);
68 is(ns.Exported, 17, "subscript from a blob URL should work");
69 ]]></script>
70 </window>