Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / chrome / test_bug771429.xhtml
blobc5846dd6ac1023bdabaf0cb9d23eb286fcc4448a
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=771429
6 -->
7 <window title="Mozilla Bug 771429"
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=771429"
14 target="_blank">Mozilla Bug 771429</a>
15 </body>
17 <!-- test code goes here -->
18 <script type="application/javascript">
19 <![CDATA[
20 /** Test for Bug 771429 **/
21 function f() {}
22 function g() { return this; }
23 function h() { "use strict"; return this; }
24 function ctor() { this.x = 1; }
25 f.x = 2;
26 f.g = g;
27 function test(freshCompartment) {
28 var s = new Cu.Sandbox(window, {
29 sandboxPrototype: window,
30 freshCompartment,
31 });
32 try {
33 is(Cu.evalInSandbox('g()', s), window,
34 "Should get window as this object of non-strict global function");
35 is(Cu.evalInSandbox('h()', s), undefined,
36 "Should get undefined as this object of strict global function");
37 is(Cu.evalInSandbox('f.x', s), 2,
38 "Should have gotten the right thing back");
39 if (freshCompartment) {
40 is(Cu.evalInSandbox('f.g()', s), f,
41 "Should have the right function object");
42 } else {
43 // In the same-compartment case we don't go through a compartment
44 // boundary so when we call f.g() we don't unwrap the "callable
45 // proxy" around f and the test above fails. We accept this slight
46 // difference in behavior and assert a weaker invariant.
47 is(Cu.evalInSandbox('f.g()', s).toString(), f.toString(),
48 "Should have the right function object");
50 is(Cu.evalInSandbox('var x = { z: 7 }; g.call(x).z', s), 7,
51 "Should not rebind calls that are already bound");
52 // And test what happens when we use the normal Function.prototype.call
53 // on g instead of whatever our proxies happen to return.
54 is(Cu.evalInSandbox('var x = { z: 7 }; Function.prototype.call.call(g, x).z', s), 7,
55 "Should not rebind calls that are already bound");
56 is(Cu.evalInSandbox('new ctor();', s).x, 1,
57 "Should get a properly constructed object out of the sandbox");
58 } catch (e) {
59 ok(false, "Should not get an exception: " + e);
62 test(false);
63 test(true);
64 ]]>
65 </script>
66 </window>