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.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <window title="Mozilla Bug 761723" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | <script type="application/javascript" |
michael@0 | 8 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | |
michael@0 | 10 | <!-- test results are displayed in the html:body --> |
michael@0 | 11 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 12 | <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=761723" target="_blank">Mozilla Bug 761723</a> |
michael@0 | 13 | </body> |
michael@0 | 14 | |
michael@0 | 15 | <!-- test code goes here --> |
michael@0 | 16 | <script type="application/javascript" src="outoflinexulscript.js"></script> |
michael@0 | 17 | <script type="application/javascript"><![CDATA[ |
michael@0 | 18 | const Cu = Components.utils; |
michael@0 | 19 | const Cc = Components.classes; |
michael@0 | 20 | const Ci = Components.interfaces; |
michael@0 | 21 | Cu.import("resource://gre/modules/NetUtil.jsm"); |
michael@0 | 22 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 23 | |
michael@0 | 24 | function inlinefunction() { |
michael@0 | 25 | return 42; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // 1 assertion in debug builds because bug 821726 added the ignoreCache switch and |
michael@0 | 29 | // we now write to the cache more than once for the same entry |
michael@0 | 30 | SimpleTest.expectAssertions(1); |
michael@0 | 31 | |
michael@0 | 32 | var src; |
michael@0 | 33 | src = inlinefunction.toSource(); |
michael@0 | 34 | isnot(src.indexOf("return 42"), -1, "inline XUL script should have source"); |
michael@0 | 35 | is(src.charAt(src.length - 1), "}", "inline XUL source should end with '}'"); |
michael@0 | 36 | src = outoflinefunction.toSource(); |
michael@0 | 37 | isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source") |
michael@0 | 38 | is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'"); |
michael@0 | 39 | src = NetUtil.asyncFetch.toSource(); |
michael@0 | 40 | isnot(src.indexOf("return"), -1, "JSM should have source"); |
michael@0 | 41 | var ns = {}; |
michael@0 | 42 | Services.scriptloader.loadSubScript("resource://gre/modules/NetUtil.jsm", ns); |
michael@0 | 43 | src = ns.NetUtil.asyncFetch.toSource(); |
michael@0 | 44 | isnot(src.indexOf("return"), -1, "subscript should have source"); |
michael@0 | 45 | |
michael@0 | 46 | var base = /.*\//.exec(window.location.href)[0]; |
michael@0 | 47 | var reg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry); |
michael@0 | 48 | var resolvedBase = reg.convertChromeURL(NetUtil.newURI(base)).spec; |
michael@0 | 49 | |
michael@0 | 50 | ns = {}; |
michael@0 | 51 | Services.scriptloader.loadSubScript(resolvedBase + "subscript.js", ns); |
michael@0 | 52 | src = ns.NetUtil.asyncFetch.toSource(); |
michael@0 | 53 | isnot(src.indexOf("return"), -1, "subscript of a subscript should have source"); |
michael@0 | 54 | |
michael@0 | 55 | ns = {}; |
michael@0 | 56 | Services.scriptloader.loadSubScript(resolvedBase + "utf8_subscript.js", ns, "UTF-8"); |
michael@0 | 57 | src = ns.f.toSource(); |
michael@0 | 58 | isnot(src.indexOf("return 42;"), -1, "encoded subscript should have correct source"); |
michael@0 | 59 | |
michael@0 | 60 | ns = {}; |
michael@0 | 61 | Services.scriptloader.loadSubScriptWithOptions(resolvedBase + "utf8_subscript.js", |
michael@0 | 62 | {target: ns, charset: "UTF-8", ignoreCache: true}); |
michael@0 | 63 | src = ns.f.toSource(); |
michael@0 | 64 | isnot(src.indexOf("return 42;"), -1, "encoded subscript should have correct source"); |
michael@0 | 65 | ]]></script> |
michael@0 | 66 | </window> |