Bug 1112001. Provide a newGlobal in jsreftests in browser. r=jorendorff
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 07 Jan 2015 09:46:05 -0500
changeset 248320 7a5175e8ba699c91751d9dcff9f4c2dd8bb54d11
parent 248319 02b4ccc6cc9109f71f44d61528d474f9b16a21e2
child 248321 93a8e6ea13241cf078bab2b2a255b94364a43215
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1112001
milestone37.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 1112001. Provide a newGlobal in jsreftests in browser. r=jorendorff
js/src/tests/browser.js
js/src/tests/ecma_5/extensions/reviver-mutates-holder-array-ccw.js
js/src/tests/ecma_5/extensions/reviver-mutates-holder-object-ccw.js
js/src/tests/ecma_6/Array/from_realms.js
--- a/js/src/tests/browser.js
+++ b/js/src/tests/browser.js
@@ -547,12 +547,22 @@ function closeDialog()
     else
     {
       // alerts inside of reftest framework are not XULDocument dialogs.
       subject.close();
     }
   }
 }
 
+function newGlobal() {
+  var iframe = document.createElement("iframe");
+  document.documentElement.appendChild(iframe);
+  var win = iframe.contentWindow;
+  iframe.remove();
+  // Shim in "evaluate"
+  win.evaluate = win.eval;
+  return win;
+}
+
 registerDialogCloser();
 window.addEventListener('unload', unregisterDialogCloser, true);
 
 jsTestDriverBrowserInit();
--- a/js/src/tests/ecma_5/extensions/reviver-mutates-holder-array-ccw.js
+++ b/js/src/tests/ecma_5/extensions/reviver-mutates-holder-array-ccw.js
@@ -10,24 +10,16 @@ var BUGNUMBER = 901351;
 var summary = "Behavior when the JSON.parse reviver mutates the holder array";
 
 print(BUGNUMBER + ": " + summary);
 
 /**************
  * BEGIN TEST *
  **************/
 
-if (typeof newGlobal !== "function")
-{
-  var newGlobal = function()
-  {
-    return { evaluate: eval };
-  };
-}
-
 var proxyObj = null;
 
 var arr = JSON.parse('[0, 1]', function(prop, v) {
   if (prop === "0")
   {
     proxyObj = newGlobal().evaluate("({ c: 17, d: 42 })");
     this[1] = proxyObj;
   }
--- a/js/src/tests/ecma_5/extensions/reviver-mutates-holder-object-ccw.js
+++ b/js/src/tests/ecma_5/extensions/reviver-mutates-holder-object-ccw.js
@@ -10,24 +10,16 @@ var BUGNUMBER = 901351;
 var summary = "Behavior when the JSON.parse reviver mutates the holder object";
 
 print(BUGNUMBER + ": " + summary);
 
 /**************
  * BEGIN TEST *
  **************/
 
-if (typeof newGlobal !== "function")
-{
-  var newGlobal = function()
-  {
-    return { evaluate: eval };
-  };
-}
-
 // A little trickiness to account for the undefined-ness of property
 // enumeration order.
 var first = "unset";
 
 var proxyObj = null;
 
 var obj = JSON.parse('{ "a": 0, "b": 1 }', function(prop, v) {
   if (first === "unset")
--- a/js/src/tests/ecma_6/Array/from_realms.js
+++ b/js/src/tests/ecma_6/Array/from_realms.js
@@ -20,17 +20,18 @@ if (typeof newGlobal === 'function') {
     assertEq(q instanceof Array, true);
 
     // The default 'this' value received by a non-strict mapping function is
     // that function's global, not Array.from's global or the caller's global.
     var h = newGlobal(), result = undefined;
     h.mainGlobal = this;
     h.eval("function f() { mainGlobal.result = this; }");
     g.Array.from.call(Array, [5, 6, 7], h.f);
-    // (Give each global in the test a name, for better error messages.)
-    this.name = "main";
-    g.name = "g";
-    h.name = "h";
-    assertEq(result.name, "h");
+    // (Give each global in the test a name, for better error messages.  But use
+    // globalName, because window.name is complicated.)
+    this.globalName = "main";
+    g.globalName = "g";
+    h.globalName = "h";
+    assertEq(result.globalName, "h");
 }
 
 if (typeof reportCompare === 'function')
     reportCompare(0, 0);