Bug 1515590 part 2 - Fix test_bug1042436.xul to create the sandbox in a new compartment because Xray warning state is stored per compartment. r=bholley
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 21 Dec 2018 18:34:12 +0000
changeset 451846 11d454511a09a05cf69b79b5013816ee82fa5794
parent 451845 80f5a69c142faaeffe0b5be2bfeb8c258ff3c4f0
child 451847 4ebe565c65f90c7b964f67dd6ed8ccf361918630
push id35264
push userbtara@mozilla.com
push dateSun, 23 Dec 2018 21:50:18 +0000
treeherdermozilla-central@223604c02a0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1515590, 1042436
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1515590 part 2 - Fix test_bug1042436.xul to create the sandbox in a new compartment because Xray warning state is stored per compartment. r=bholley Differential Revision: https://phabricator.services.mozilla.com/D15092
js/xpconnect/tests/chrome/test_bug1042436.xul
--- a/js/xpconnect/tests/chrome/test_bug1042436.xul
+++ b/js/xpconnect/tests/chrome/test_bug1042436.xul
@@ -22,27 +22,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   var contentSb = Cu.Sandbox('http://www.example.com');
   var nonXrayableObj = contentSb.eval("new Map()[Symbol.iterator]()");
   nonXrayableObj.wrappedJSObject.someExpandoProperty = 42;
   nonXrayableObj.wrappedJSObject.someOtherExpandoProperty = 52;
 
 
   SimpleTest.expectConsoleMessages(function() {
-      nonXrayableObj.someExpandoProperty;
-      nonXrayableObj.someOtherExpandoProperty;
+      // Create sandboxes in fresh compartments, because the warning state is
+      // stored per compartment.
+      var chromeSb1 = Cu.Sandbox(this, {freshCompartment: true});
+      chromeSb1.nonXrayableObj = nonXrayableObj;
+      Cu.evalInSandbox(`
+        nonXrayableObj.someExpandoProperty;
+        nonXrayableObj.someOtherExpandoProperty;
+      `, chromeSb1);
 
-      var chromeSb = Cu.Sandbox(this);
+      var chromeSb2 = Cu.Sandbox(this, {freshCompartment: true});
       var contentObjWithGetter = contentSb.eval('({ get getterProp() {return 42;}, valueProp: 42 })');
       is(contentObjWithGetter.wrappedJSObject.getterProp, 42, "Getter prop set up correctly");
       is(contentObjWithGetter.getterProp, undefined, "Xrays work right");
       is(contentObjWithGetter.valueProp, 42, "Getter prop set up correctly");
-      chromeSb.contentObjWithGetter = contentObjWithGetter;
+      chromeSb2.contentObjWithGetter = contentObjWithGetter;
       Cu.evalInSandbox('contentObjWithGetter.getterProp; contentObjWithGetter.valueProp; contentObjWithGetter.getterProp;',
-                       chromeSb, "1.7", "http://phony.example.com/file.js", 99);
+                       chromeSb2, "1.7", "http://phony.example.com/file.js", 99);
   },
   [{ errorMessage: /property "someExpandoProperty" \(reason: object is not safely Xrayable/, sourceName: /test_bug1042436/, isWarning: true },
    { errorMessage: /property "getterProp" \(reason: property has accessor/, sourceName: /phony/, lineNumber: 99, isWarning: true } ],
   SimpleTest.finish.bind(SimpleTest));
 
   ]]>
   </script>
 </window>