2 <?xml-stylesheet type=
"text/css" href=
"chrome://global/skin"?>
3 <?xml-stylesheet type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"?>
5 https://bugzilla.mozilla.org/show_bug.cgi?id=990353
7 <window title=
"Mozilla Bug 990353"
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <!-- test results are displayed in the html:body -->
12 <body xmlns=
"http://www.w3.org/1999/xhtml">
13 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=990353"
14 target=
"_blank">Mozilla Bug
990353</a>
17 <!-- test code goes here -->
18 <script type=
"application/javascript">
20 /** Test for Bug
990353 **/
21 SimpleTest.waitForExplicitFinish();
24 // eslint-disable-next-line no-unused-vars
25 var someBitOfSource =
42;
29 function frameLoaded() {
30 switch (++gLoadCount) {
32 ok(/native code/.test(window[
0].canary.toString()),
"System function should be sourceless: " + window[
0].canary.toString());
33 ok(/native code/.test(window[
0].onload.toString()),
"System event handler should be sourceless: " + window[
0].onload.toString());
34 var sb = new Cu.Sandbox(
"https://www.example.com", { discardSource: true });
35 Cu.evalInSandbox('function canary() { var someBitOfSource =
42; }', sb);
36 ok(/native code/.test(sb.canary.toString()),
"Function from sandbox with explicit discarding should be sourceless");
38 window[
0].throwSomething();
39 ok(false,
"should have thrown");
41 ok(/some error/.test(e),
"Threw exception as expected: " + e);
42 ok(/throwSomething/.test(e.stack),
"Exception stack trace works: " + e.stack);
44 window[
0].location =
"https://example.org/tests/js/xpconnect/tests/chrome/file_discardSystemSource.html";
47 ok(/someBitOfSource/.test(Cu.waiveXrays(window[
0]).canary.toString()),
"Content function should have source");
48 ok(/someBitOfSource/.test(Cu.waiveXrays(window[
0]).onload.toString()),
"Content event handler should have source");
54 function testWorker() {
55 var worker = new window[
0].wrappedJSObject.Worker('worker_discardSystemSource.js');
56 worker.onmessage = function(evt) {
57 ok(/someBitOfSource/.test(evt.data),
"Non-chrome worker should have source: " + evt.data);
58 var chromeWorker = new Worker('worker_discardSystemSource.js');
59 chromeWorker.onmessage = function(evt) {
60 ok(/native code/.test(evt.data),
"Chrome worker should not have source: " + evt.data);
67 // We should have our own source, because the pref wasn't enabled when we
69 ok(/someBitOfSource/.test(canary.toString()),
"Should have own source");
71 window[
0].frameElement.onload = frameLoaded;
72 window[
0].location =
"file_discardSystemSource.html";
74 addLoadEvent(function() {
75 SpecialPowers.pushPrefEnv({set: [['javascript.options.discardSystemSource', true]]}, go);