test_bug1042436.xhtml (2508B)
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=1042436 6 --> 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"/> 10 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> 15 </body> 16 17 <!-- test code goes here --> 18 <script type="application/javascript"> 19 <![CDATA[ 20 /** Test for Bug 1042436 */ 21 SimpleTest.waitForExplicitFinish(); 22 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; 27 28 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; 34 Cu.evalInSandbox(` 35 nonXrayableObj.someExpandoProperty; 36 nonXrayableObj.someOtherExpandoProperty; 37 `, chromeSb1); 38 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); 47 }, 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)); 51 52 ]]> 53 </script> 54 </window>