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=1042436
7 <window title=
"Mozilla Bug 1042436"
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=1042436"
14 target=
"_blank">Mozilla Bug
1042436</a>
17 <!-- test code goes here -->
18 <script type=
"application/javascript">
20 /** Test for Bug
1042436 **/
21 SimpleTest.waitForExplicitFinish();
23 var contentSb = Cu.Sandbox(
"https://www.example.com");
24 var nonXrayableObj = contentSb.eval(
"new Map()[Symbol.iterator]()");
25 nonXrayableObj.wrappedJSObject.someExpandoProperty =
42;
26 nonXrayableObj.wrappedJSObject.someOtherExpandoProperty =
52;
29 SimpleTest.expectConsoleMessages(function() {
30 // Create sandboxes in fresh compartments, because the warning state is
31 // stored per compartment.
32 var chromeSb1 = Cu.Sandbox(this, {freshCompartment: true});
33 chromeSb1.nonXrayableObj = nonXrayableObj;
35 nonXrayableObj.someExpandoProperty;
36 nonXrayableObj.someOtherExpandoProperty;
39 var chromeSb2 = Cu.Sandbox(this, {freshCompartment: true});
40 var contentObjWithGetter = contentSb.eval('({ get getterProp() {return
42;}, valueProp:
42 })');
41 is(contentObjWithGetter.wrappedJSObject.getterProp,
42,
"Getter prop set up correctly");
42 is(contentObjWithGetter.getterProp, undefined,
"Xrays work right");
43 is(contentObjWithGetter.valueProp,
42,
"Getter prop set up correctly");
44 chromeSb2.contentObjWithGetter = contentObjWithGetter;
45 Cu.evalInSandbox('contentObjWithGetter.getterProp; contentObjWithGetter.valueProp; contentObjWithGetter.getterProp;',
46 chromeSb2,
"1.7",
"https://phony.example.com/file.js",
99);
48 [{ errorMessage: /property
"someExpandoProperty" \(reason: object is not safely Xrayable/, sourceName: /test_bug1042436/, isWarning: true },
49 { errorMessage: /property
"getterProp" \(reason: property has accessor/, sourceName: /phony/, lineNumber:
99, isWarning: true } ],
50 SimpleTest.finish.bind(SimpleTest));