Bug 858101 - Fix other tests. r=mrbkap, a=akeybl
authorBobby Holley <bobbyholley@gmail.com>
Fri, 31 May 2013 10:36:02 -0700
changeset 138630 de4fa126dd9f26add2e94d4e30ecd85fe6727816
parent 138629 e63d4899efc0fb3195cbe75262bb034e7680b2d9
child 138631 9107b23403c507f50c32f1118b1e5ef97ba2376d
push id3829
push userryanvm@gmail.com
push dateMon, 03 Jun 2013 13:09:51 +0000
treeherdermozilla-aurora@de4fa126dd9f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, akeybl
bugs858101
milestone23.0a2
Bug 858101 - Fix other tests. r=mrbkap, a=akeybl
dom/tests/browser/browser_ConsoleAPITests.js
dom/tests/mochitest/chrome/test_sandbox_bindings.xul
--- a/dom/tests/browser/browser_ConsoleAPITests.js
+++ b/dom/tests/browser/browser_ConsoleAPITests.js
@@ -43,17 +43,24 @@ function testConsoleData(aMessageObject)
   if (gLevel == "trace") {
     is(aMessageObject.arguments.length, 0, "arguments.length matches");
     is(aMessageObject.stacktrace.toSource(), gArgs.toSource(),
        "stack trace is correct");
   }
   else {
     is(aMessageObject.arguments.length, gArgs.length, "arguments.length matches");
     gArgs.forEach(function (a, i) {
-      is(aMessageObject.arguments[i], a, "correct arg " + i);
+      // Waive Xray so that we don't get messed up by Xray ToString.
+      //
+      // It'd be nice to just use XPCNativeWrapper.unwrap here, but there are
+      // a number of dumb reasons we can't. See bug 868675.
+      var arg = aMessageObject.arguments[i];
+      if (Components.utils.isXrayWrapper(arg))
+        arg = arg.wrappedJSObject;
+      is(arg, a, "correct arg " + i);
     });
   }
 
   gTestDriver.next();
 }
 
 function testLocationData(aMessageObject) {
   let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
--- a/dom/tests/mochitest/chrome/test_sandbox_bindings.xul
+++ b/dom/tests/mochitest/chrome/test_sandbox_bindings.xul
@@ -17,28 +17,28 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   /** Test for Bug 741267 **/
     function isXrayWrapper(x) {
-      return XPCNativeWrapper.unwrap(x) != x;
+      return Components.utils.isXrayWrapper(x);
     }
 
     function doTest() {
       var win = $("t").contentWindow;
       var sandbox = Components.utils.Sandbox(win, { sandboxPrototype: win });
 
       is(sandbox._content, undefined, "_content does nothing over Xray");
 
       try {
         var css = Components.utils.evalInSandbox("CSSStyleDeclaration", sandbox);
-        is(css.prototype, "[object CSSStyleDeclarationPrototype]", "'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
+        is(css.prototype, "[object XrayWrapper [object CSSStyleDeclarationPrototype]]", "'CSSStyleDeclaration.prototype' in a sandbox should return the CSSStyleDeclaration interface prototype object");
       } catch (e) {
         ok(false, "'CSSStyleDeclaration' shouldn't throw in a sandbox");
       }
       try {
         var et = Components.utils.evalInSandbox("EventTarget", sandbox);
         ok(et, "'EventTarget' in a sandbox should return the EventTarget interface object");
         ok(isXrayWrapper(et), "Getting an interface object on an Xray wrapper should return an Xray wrapper");
       } catch (e) {
@@ -87,17 +87,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         var xhr = Components.utils.evalInSandbox("XMLHttpRequest", sandbox);
         is(xhr, "[object XrayWrapper " + XMLHttpRequest + "]", "'XMLHttpRequest' in a sandbox should return the XMLHttpRequest interface object");
         ok(isXrayWrapper(xhr.prototype), "Getting the prototype property on an Xray wrapper of an interface object should return an Xray wrapper");
       } catch (e) {
         ok(false, "'XMLHttpRequest' shouldn't throw in a sandbox");
       }
       try {
         var xhr = Components.utils.evalInSandbox("XMLHttpRequest()", sandbox);
-        is("" + xhr, "" + XMLHttpRequest(), "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
+        is("" + xhr, "[object XrayWrapper " + XMLHttpRequest() + "]", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
       } catch (e) {
         ok(false, "'XMLHttpRequest()' shouldn't throw in a sandbox");
       }
       try {
         var xhr = Components.utils.evalInSandbox("XMLHttpRequest.prototype.toString = function () { return 'Failed'; }; XMLHttpRequest();", sandbox);
         is(xhr.toString(), "[object XrayWrapper " + XMLHttpRequest() + "]", "XMLHttpRequest.prototype.toString in the sandbox should not override the native toString behaviour");
       } catch (e) {
         ok(false, "'new XMLHttpRequest()' shouldn't throw in a sandbox");
@@ -119,17 +119,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       } catch (e) {
         ok(false, "XMLHttpRequest.prototype manipulation via an Xray shouldn't throw" + e);
       }
 
       try {
         Components.utils.evalInSandbox("document.defaultView.XMLHttpRequest = function() {};", sandbox);
         var win = Components.utils.evalInSandbox("document.defaultView", sandbox);
         var xhr = win.XMLHttpRequest();
-        is("" + xhr, "" + XMLHttpRequest(), "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
+        is("" + xhr, "[object XrayWrapper " + XMLHttpRequest() + "]", "'XMLHttpRequest()' in a sandbox should create an XMLHttpRequest object");
       } catch (e) {
         ok(false, "'XMLHttpRequest()' shouldn't throw in a sandbox");
       }
       try {
         var canvas = Components.utils.evalInSandbox("document.createElement('canvas').getContext('2d')", sandbox);
         is(canvas.DRAWWINDOW_DRAW_CARET, CanvasRenderingContext2D.DRAWWINDOW_DRAW_CARET, "Constants should be defined on DOM objects in a sandbox");
       } catch (e) {
         ok(false, "'document.createElement('canvas').getContext('2D')' shouldn't throw in a sandbox");