Bug 844169 - Part 3: Make sure that all callers of HTMLIFrameElement.mozbrowser have chrome privileges; r=bzbarsky
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 26 Feb 2013 21:26:10 -0500
changeset 123167 ff43e3133f5a9cef574f9e4ff2b596849c3eae03
parent 123166 4cc81e04c718065583eb0bec03ba7d4c747b1fce
child 123168 a28ab17cb0c05737acec405391f3f67d0063d5e5
push id24373
push userryanvm@gmail.com
push dateThu, 28 Feb 2013 01:36:21 +0000
treeherdermozilla-central@8cb9d6981978 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs844169
milestone22.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 844169 - Part 3: Make sure that all callers of HTMLIFrameElement.mozbrowser have chrome privileges; r=bzbarsky
content/base/test/test_child_process_shutdown_message.html
content/base/test/test_ipc_messagemanager_blob.html
content/base/test/test_messagemanager_assertpermission.html
dom/browser-element/mochitest/browserElement_Alert.js
dom/browser-element/mochitest/browserElement_AlertInFrame.js
dom/browser-element/mochitest/browserElement_AppFramePermission.js
dom/browser-element/mochitest/browserElement_AppWindowNamespace.js
dom/browser-element/mochitest/browserElement_Auth.js
dom/browser-element/mochitest/browserElement_BackForward.js
dom/browser-element/mochitest/browserElement_BadScreenshot.js
dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
dom/browser-element/mochitest/browserElement_Close.js
dom/browser-element/mochitest/browserElement_CloseApp.js
dom/browser-element/mochitest/browserElement_CloseFromOpener.js
dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
dom/browser-element/mochitest/browserElement_DOMRequestError.js
dom/browser-element/mochitest/browserElement_DataURI.js
dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
dom/browser-element/mochitest/browserElement_ErrorSecurity.js
dom/browser-element/mochitest/browserElement_ExposableURI.js
dom/browser-element/mochitest/browserElement_FirstPaint.js
dom/browser-element/mochitest/browserElement_ForwardName.js
dom/browser-element/mochitest/browserElement_FrameWrongURI.js
dom/browser-element/mochitest/browserElement_GetScreenshot.js
dom/browser-element/mochitest/browserElement_Iconchange.js
dom/browser-element/mochitest/browserElement_KeyEvents.js
dom/browser-element/mochitest/browserElement_LoadEvents.js
dom/browser-element/mochitest/browserElement_NextPaint.js
dom/browser-element/mochitest/browserElement_OpenMixedProcess.js
dom/browser-element/mochitest/browserElement_OpenNamed.js
dom/browser-element/mochitest/browserElement_OpenWindow.js
dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
dom/browser-element/mochitest/browserElement_PromptCheck.js
dom/browser-element/mochitest/browserElement_PromptConfirm.js
dom/browser-element/mochitest/browserElement_PurgeHistory.js
dom/browser-element/mochitest/browserElement_Reload.js
dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
dom/browser-element/mochitest/browserElement_ScrollEvent.js
dom/browser-element/mochitest/browserElement_SecurityChange.js
dom/browser-element/mochitest/browserElement_SendEvent.js
dom/browser-element/mochitest/browserElement_SetVisible.js
dom/browser-element/mochitest/browserElement_SetVisibleFrames.js
dom/browser-element/mochitest/browserElement_SetVisibleFrames2.js
dom/browser-element/mochitest/browserElement_Stop.js
dom/browser-element/mochitest/browserElement_TargetBlank.js
dom/browser-element/mochitest/browserElement_TargetTop.js
dom/browser-element/mochitest/browserElement_Titlechange.js
dom/browser-element/mochitest/browserElement_TopBarrier.js
dom/browser-element/mochitest/browserElement_XFrameOptions.js
dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
dom/browser-element/mochitest/createNewTest.py
dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html
dom/browser-element/mochitest/file_browserElement_SetVisibleFrames_Outer.html
dom/browser-element/mochitest/test_browserElement_NoPref.html
dom/browser-element/mochitest/test_browserElement_NoWhitelist.html
dom/devicestorage/ipc/test_ipc.html
dom/indexedDB/ipc/test_ipc.html
layout/base/tests/test_remote_frame.html
--- a/content/base/test/test_child_process_shutdown_message.html
+++ b/content/base/test/test_child_process_shutdown_message.html
@@ -29,17 +29,17 @@ let ppmm = SpecialPowers.Cc["@mozilla.or
  * @param isApp
  *        If true, the example.org site will be loaded as an app.
  */
 function loadBrowser(isApp, callback) {
   let iframe = document.createElement("iframe");
   if (isApp) {
     iframe.setAttribute("mozapp", APP_MANIFEST);
   }
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.src = APP_URL;
   document.getElementById("content").appendChild(iframe);
 
   iframe.addEventListener("mozbrowserloadend", function onloadend() {
     iframe.removeEventListener("mozbrowserloadend", onloadend);
     callback(iframe);
   });
 }
--- a/content/base/test/test_ipc_messagemanager_blob.html
+++ b/content/base/test/test_ipc_messagemanager_blob.html
@@ -38,17 +38,17 @@
         reader.readAsText(message.json);
       });
     }
 
     function runTests() {
       ok("Browser prefs set.");
 
       let iframe = document.createElement("iframe");
-      iframe.mozbrowser = true;
+      SpecialPowers.wrap(iframe).mozbrowser = true;
       iframe.id = "iframe";
       iframe.src = childFrameURL;
 
       iframe.addEventListener("mozbrowserloadend", function() {
         ok(true, "Got iframe load event.");
 
         const messages = [
           "hi!",
--- a/content/base/test/test_messagemanager_assertpermission.html
+++ b/content/base/test/test_messagemanager_assertpermission.html
@@ -40,17 +40,17 @@ function setUp() {
 }
 
 /**
  * Load the example.org app in an <iframe mozbrowser mozapp>
  */
 function loadApp(callback) {
   let iframe = document.createElement("iframe");
   iframe.setAttribute("mozapp", APP_MANIFEST);
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.src = APP_URL;
   document.getElementById("content").appendChild(iframe);
 
   iframe.addEventListener("mozbrowserloadend", function onloadend() {
     iframe.removeEventListener("mozbrowserloadend", onloadend);
     callback(iframe);
   });
 }
--- a/dom/browser-element/mochitest/browserElement_Alert.js
+++ b/dom/browser-element/mochitest/browserElement_Alert.js
@@ -10,17 +10,17 @@ var numPendingChildTests = 0;
 var iframe;
 var mm;
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
   mm.addMessageListener('test-success', function(msg) {
     numPendingChildTests--;
     ok(true, SpecialPowers.wrap(msg).json);
   });
   mm.addMessageListener('test-fail', function(msg) {
--- a/dom/browser-element/mochitest/browserElement_AlertInFrame.js
+++ b/dom/browser-element/mochitest/browserElement_AlertInFrame.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     is(e.detail.message, 'Hello');
     SimpleTest.finish();
   });
 
   iframe.src = 'file_browserElement_AlertInFrame.html';
   document.body.appendChild(iframe);
--- a/dom/browser-element/mochitest/browserElement_AppFramePermission.js
+++ b/dom/browser-element/mochitest/browserElement_AppFramePermission.js
@@ -21,17 +21,17 @@ function makeAllAppsLaunchable() {
       appRegistry.allAppsLaunchable = originalValue;
     }
   }, false);
 }
 makeAllAppsLaunchable();
 
 function testAppElement(expectAnApp, callback) {
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     is(e.detail.message == 'app', expectAnApp, e.detail.message);
     SimpleTest.executeSoon(callback);
   });
   document.body.appendChild(iframe);
   iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppFramePermission.html';
 }
--- a/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js
+++ b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js
@@ -8,30 +8,30 @@ SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
   // Permission to embed an app.
   SpecialPowers.addPermission("embed-apps", true, document);
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp');
 
   // Two mozapp frames for different apps with the same code both do the same
   // window.open("foo", "bar") call.  We should get two mozbrowseropenwindow
   // events.
 
   iframe1.addEventListener('mozbrowseropenwindow', function(e) {
     ok(true, "Got first mozbrowseropenwindow event.");
     document.body.appendChild(e.detail.frameElement);
 
     SimpleTest.executeSoon(function() {
       var iframe2 = document.createElement('iframe');
-      iframe2.mozbrowser = true;
+      SpecialPowers.wrap(iframe2).mozbrowser = true;
       iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp');
 
       iframe2.addEventListener('mozbrowseropenwindow', function(e) {
         ok(true, "Got second mozbrowseropenwindow event.");
         SpecialPowers.removePermission("embed-apps", document);
         SimpleTest.finish();
       });
 
--- a/dom/browser-element/mochitest/browserElement_Auth.js
+++ b/dom/browser-element/mochitest/browserElement_Auth.js
@@ -12,17 +12,17 @@ function testFail(msg) {
 
 var iframe;
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   // Wait for the initial load to finish, then navigate the page, then start test
   // by loading SJS with http 401 response.
   iframe.addEventListener('mozbrowserloadend', function loadend() {
     iframe.removeEventListener('mozbrowserloadend', loadend);
     iframe.addEventListener('mozbrowserusernameandpasswordrequired', testHttpAuthCancel);
     SimpleTest.executeSoon(function() {
--- a/dom/browser-element/mochitest/browserElement_BackForward.js
+++ b/dom/browser-element/mochitest/browserElement_BackForward.js
@@ -17,17 +17,17 @@ function addOneShotIframeEventListener(e
   iframe.addEventListener(event, wrapper);
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   addOneShotIframeEventListener('mozbrowserloadend', function() {
     SimpleTest.executeSoon(test2);
   });
 
   iframe.src = browserElementTestHelpers.emptyPage1;
   document.body.appendChild(iframe);
 }
--- a/dom/browser-element/mochitest/browserElement_BadScreenshot.js
+++ b/dom/browser-element/mochitest/browserElement_BadScreenshot.js
@@ -42,17 +42,17 @@ function checkScreenshotResult(expectSuc
   };
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
   iframe.src = 'data:text/html,<html>' +
     '<body style="background:green">hello</body></html>';
 
   iframe.addEventListener('mozbrowserfirstpaint', function() {
     // This one should succeed.
     checkScreenshotResult(true, [100, 100]);
 
--- a/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
+++ b/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
@@ -9,17 +9,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
 
   // Two mozbrowser frames with the same code both do the same
   // window.open("foo", "bar") call.  We should only get one
   // mozbrowseropenwindow event.
 
   iframe1.addEventListener('mozbrowseropenwindow', function(e) {
     ok(true, "Got first mozbrowseropenwindow event.");
     document.body.appendChild(e.detail.frameElement);
@@ -31,17 +31,17 @@ function runTest() {
       }
       else {
         ok(true, "Got locationchange to " + e.detail);
       }
     });
 
     SimpleTest.executeSoon(function() {
       var iframe2 = document.createElement('iframe');
-      iframe2.mozbrowser = true;
+      SpecialPowers.wrap(iframe2).mozbrowser = true;
 
       iframe2.addEventListener('mozbrowseropenwindow', function(e) {
         ok(false, "Got second mozbrowseropenwindow event.");
       });
 
       document.body.appendChild(iframe2);
       iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2';
     });
--- a/dom/browser-element/mochitest/browserElement_Close.js
+++ b/dom/browser-element/mochitest/browserElement_Close.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowserclose", function(e) {
     ok(true, "got mozbrowserclose event.");
     SimpleTest.finish();
   });
 
   iframe.src = "data:text/html,<html><body><script>window.close()</scr"+"ipt></body></html>";
--- a/dom/browser-element/mochitest/browserElement_CloseApp.js
+++ b/dom/browser-element/mochitest/browserElement_CloseApp.js
@@ -17,21 +17,21 @@ function runTest() {
   });
 
   // Our app frame and browser frame load the same content.  That content calls
   // window.close() and then alert().  We should get a mozbrowserclose event on
   // the app frame before the mozbrowsershowmodalprompt, but not on the browser
   // frame.
 
   var appFrame = document.createElement('iframe');
-  appFrame.mozbrowser = true;
+  SpecialPowers.wrap(appFrame).mozbrowser = true;
   appFrame.setAttribute('mozapp', 'http://example.org/manifest.webapp');
 
   var browserFrame = document.createElement('iframe');
-  browserFrame.mozbrowser = true;
+  SpecialPowers.wrap(browserFrame).mozbrowser = true;
 
   var gotAppFrameClose = false;
   appFrame.addEventListener('mozbrowserclose', function() {
     ok(true, "Got close from app frame.");
     gotAppFrameClose = true;
   });
 
   var gotAppFrameAlert = false;
--- a/dom/browser-element/mochitest/browserElement_CloseFromOpener.js
+++ b/dom/browser-element/mochitest/browserElement_CloseFromOpener.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     ok(true, "got openwindow event.");
     document.body.appendChild(e.detail.frameElement);
 
     e.detail.frameElement.addEventListener("mozbrowserclose", function(e) {
       ok(true, "got mozbrowserclose event.");
       SimpleTest.finish();
--- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
+++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
@@ -29,17 +29,17 @@ var trigger1 = function() {
 };
 
 function runTest() {
 
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   document.body.appendChild(iframe1);
   iframe1.src = 'data:text/html,<html>' +
     '<body>' +
     '<menu type="context" id="menu1" label="firstmenu">' +
       '<menuitem label="foo" onclick="window.ctxCallbackFired(\'foo\')"></menuitem>' +
       '<menuitem label="bar" onclick="throw(\'anerror\')"></menuitem>' +
     '</menu>' +
     '<menu type="context" id="menu2" label="secondmenu">' +
--- a/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
+++ b/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
@@ -9,17 +9,17 @@ SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   const innerPage = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html';
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     if (e.detail.message == 'next') {
       iframe.src = innerPage + '?step=2';
       return;
     }
 
     if (e.detail.message.startsWith('success:')) {
--- a/dom/browser-element/mochitest/browserElement_DOMRequestError.js
+++ b/dom/browser-element/mochitest/browserElement_DOMRequestError.js
@@ -7,17 +7,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   iframe1.src = 'data:text/html,<html>' +
     '<body style="background:green">hello</body></html>';
   document.body.appendChild(iframe1);
 
   function testIframe(beforeRun, isErrorExpected, nextTest) {
     return function() {
       var error = false;
       if (beforeRun)
--- a/dom/browser-element/mochitest/browserElement_DataURI.js
+++ b/dom/browser-element/mochitest/browserElement_DataURI.js
@@ -6,17 +6,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   iframe1.id = 'iframe1';
   iframe1.addEventListener('mozbrowserloadend', function if1_loadend() {
     iframe1.removeEventListener('mozbrowserloadend', if1_loadend);
     ok(true, 'Got first loadend event.');
     SimpleTest.executeSoon(runTest2);
   });
   iframe1.src = browserElementTestHelpers.emptyPage1;
   document.body.appendChild(iframe1);
--- a/dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
+++ b/dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
@@ -57,14 +57,14 @@ function testFirstLoad() {
   iframe.src = browserElementTestHelpers.emptyPage1;
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   runTestQueue([testFirstLoad, testReload, testChangeLocation]);
 }
 
 runTest();
--- a/dom/browser-element/mochitest/browserElement_ErrorSecurity.js
+++ b/dom/browser-element/mochitest/browserElement_ErrorSecurity.js
@@ -7,17 +7,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener("mozbrowsererror", function(e) {
     ok(true, "Got mozbrowsererror event.");
     ok(e.detail.type, "Event's detail has a |type| param.");
     SimpleTest.finish();
   });
 
   iframe.src = "https://expired.example.com";
--- a/dom/browser-element/mochitest/browserElement_ExposableURI.js
+++ b/dom/browser-element/mochitest/browserElement_ExposableURI.js
@@ -44,14 +44,14 @@ function testWyciwyg() {
   iframe.addEventListener('mozbrowserlocationchange', locationchange);
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
   testWyciwyg();
 }
 
 addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
--- a/dom/browser-element/mochitest/browserElement_FirstPaint.js
+++ b/dom/browser-element/mochitest/browserElement_FirstPaint.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var gotFirstPaint = false;
   var gotFirstLocationChange = false;
   iframe.addEventListener('mozbrowserfirstpaint', function(e) {
     ok(!gotFirstPaint, "Got only one first paint.");
     gotFirstPaint = true;
 
     if (gotFirstLocationChange) {
--- a/dom/browser-element/mochitest/browserElement_ForwardName.js
+++ b/dom/browser-element/mochitest/browserElement_ForwardName.js
@@ -8,17 +8,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.setAttribute('name', 'foo');
 
   iframe.addEventListener("mozbrowseropenwindow", function(e) {
     ok(false, 'Got mozbrowseropenwindow, but should not have.');
   });
 
   iframe.addEventListener('mozbrowserlocationchange', function(e) {
     ok(true, "Got locationchange to " + e.detail);
--- a/dom/browser-element/mochitest/browserElement_FrameWrongURI.js
+++ b/dom/browser-element/mochitest/browserElement_FrameWrongURI.js
@@ -6,31 +6,31 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframeJS = document.createElement('iframe');
-  iframeJS.mozbrowser = true;
+  SpecialPowers.wrap(iframeJS).mozbrowser = true;
 
   iframeJS.addEventListener('mozbrowserloadstart', function(e) {
     ok(false, "This should not happen!");
   });
 
   iframeJS.addEventListener('mozbrowserloadend', function(e) {
     ok(false, "This should not happen!");
   });
 
   iframeJS.src = 'javascript:alert("Foo");';
   document.body.appendChild(iframeJS);
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var gotPopup = false;
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     is(gotPopup, false, 'Should get just one popup.');
     gotPopup = true;
 
     document.body.appendChild(e.detail.frameElement);
   });
--- a/dom/browser-element/mochitest/browserElement_GetScreenshot.js
+++ b/dom/browser-element/mochitest/browserElement_GetScreenshot.js
@@ -7,17 +7,17 @@
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
 
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   document.body.appendChild(iframe1);
   iframe1.src = 'data:text/html,<html>' +
     '<body style="background:green">hello</body></html>';
 
   var screenshotArrayBuffers = [];
   var numLoaded = 0;
 
   function screenshotTaken(screenshotArrayBuffer) {
--- a/dom/browser-element/mochitest/browserElement_Iconchange.js
+++ b/dom/browser-element/mochitest/browserElement_Iconchange.js
@@ -14,24 +14,24 @@ function createLink(name) {
   return '<link rel="icon" type="image/png" href="http://example.com/' + name + '.png">';
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   document.body.appendChild(iframe1);
 
   // iframe2 is a red herring; we modify its favicon but don't listen for
   // iconchanges; we want to make sure that its iconchange events aren't
   // picked up by the listener on iframe1.
   var iframe2 = document.createElement('iframe');
-  iframe2.mozbrowser = true;
+  SpecialPowers.wrap(iframe2).mozbrowser = true;
   document.body.appendChild(iframe2);
 
   // iframe3 is another red herring.  It's not a mozbrowser, so we shouldn't
   // get any iconchange events on it.
   var iframe3 = document.createElement('iframe');
   document.body.appendChild(iframe3);
 
   var numIconChanges = 0;
--- a/dom/browser-element/mochitest/browserElement_KeyEvents.js
+++ b/dom/browser-element/mochitest/browserElement_KeyEvents.js
@@ -18,17 +18,17 @@ let whitelistedEvents = [
 
 SimpleTest.waitForExplicitFinish();
 
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.setOOPDisabledPref(true); // this is breaking the autofocus.
 
 var iframe = document.createElement('iframe');
-iframe.mozbrowser = true;
+SpecialPowers.wrap(iframe).mozbrowser = true;
 iframe.src = browserElementTestHelpers.focusPage;
 document.body.appendChild(iframe);
 
 // Number of expected events at which point we will consider the test as done.
 var nbEvents = whitelistedEvents.length * 3;
 
 function eventHandler(e) {
   ok(((e.type == 'keydown' || e.type == 'keypress' || e.type == 'keyup') &&
--- a/dom/browser-element/mochitest/browserElement_LoadEvents.js
+++ b/dom/browser-element/mochitest/browserElement_LoadEvents.js
@@ -16,17 +16,17 @@ function runTest() {
   //
   // This should trigger loadstart, locationchange, and loadend events.
 
   var seenLoadEnd = false;
   var seenLoadStart = false;
   var seenLocationChange = false;
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.id = 'iframe';
   iframe.src = browserElementTestHelpers.emptyPage1;
 
   function loadstart(e) {
     ok(e.isTrusted, 'Event should be trusted.');
     ok(!seenLoadEnd, 'loadstart before loadend.');
     ok(!seenLoadStart, 'Just one loadstart event.');
     ok(!seenLocationChange, 'loadstart before locationchange.');
--- a/dom/browser-element/mochitest/browserElement_NextPaint.js
+++ b/dom/browser-element/mochitest/browserElement_NextPaint.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   // Add a first listener that we'll remove shortly after.
   iframe.addNextPaintListener(wrongListener);
 
   var gotFirstNextPaintEvent = false;
   iframe.addNextPaintListener(function () {
     ok(!gotFirstNextPaintEvent, 'got the first nextpaint event');
--- a/dom/browser-element/mochitest/browserElement_OpenMixedProcess.js
+++ b/dom/browser-element/mochitest/browserElement_OpenMixedProcess.js
@@ -24,17 +24,17 @@ function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   // We're going to open a remote frame if OOP off by default.  If OOP is on by
   // default, we're going to open an in-process frame.
   var remote = !browserElementTestHelpers.getOOPByDefaultPref();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.setAttribute('remote', remote);
 
   // The page we load does window.open, then checks some things and reports
   // back using alert().  Finally, it calls alert('finish').
   //
   // Bug 776129 in particular manifests itself such that the popup frame loads
   // and the tests in file_browserElement_OpenMixedProcess pass, but the
   // content of the frame is invisible.  To catch this case, we take a
--- a/dom/browser-element/mochitest/browserElement_OpenNamed.js
+++ b/dom/browser-element/mochitest/browserElement_OpenNamed.js
@@ -9,17 +9,17 @@ SimpleTest.waitForExplicitFinish();
 
 var iframe;
 var popupFrame;
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var gotPopup = false;
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     is(gotPopup, false, 'Should get just one popup.');
     gotPopup = true;
     popupFrame = e.detail.frameElement;
     is(popupFrame.getAttribute('name'), 'OpenNamed');
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindow.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindow.js
@@ -6,17 +6,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var gotPopup = false;
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     is(gotPopup, false, 'Should get just one popup.');
     gotPopup = true;
 
     document.body.appendChild(e.detail.frameElement);
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
@@ -6,17 +6,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     ok(true, 'Got first window.open call');
 
     e.detail.frameElement.addEventListener('mozbrowseropenwindow', function(e) {
       ok(true, 'Got second window.open call');
       document.body.appendChild(e.detail.frameElement);
     });
--- a/dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
@@ -12,17 +12,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var gotPopup = false;
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     is(gotPopup, false, 'Should get just one popup.');
     gotPopup = true;
 
     document.body.appendChild(e.detail.frameElement);
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
@@ -7,17 +7,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     ok(e.detail.url.indexOf('does_not_exist.html') != -1,
        'Opened URL; got ' + e.detail.url);
     is(e.detail.name, '');
     is(e.detail.features, '');
 
     // Don't add e.detail.frameElement to the DOM, so the window.open is
--- a/dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
@@ -11,17 +11,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     ok(e.detail.url.indexOf('does_not_exist.html') != -1,
        'Opened URL; got ' + e.detail.url);
     is(e.detail.name, '');
     is(e.detail.features, '');
 
     // Call preventDefault, but don't add the iframe to the DOM.  This still
--- a/dom/browser-element/mochitest/browserElement_PromptCheck.js
+++ b/dom/browser-element/mochitest/browserElement_PromptCheck.js
@@ -21,17 +21,17 @@ var oldDialogTimeLimitPref;
 try {
   oldDialogTimeLimitPref = SpecialPowers.getIntPref(dialogTimeLimitPrefName);
 }
 catch(e) {}
 
 SpecialPowers.setIntPref(dialogTimeLimitPrefName, 10);
 
 var iframe = document.createElement('iframe');
-iframe.mozbrowser = true;
+SpecialPowers.wrap(iframe).mozbrowser = true;
 document.body.appendChild(iframe);
 
 var numPrompts = 0;
 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
   is(e.detail.message, numPrompts, "prompt message");
   if (numPrompts / 10 < 1) {
     is(e.detail.promptType, 'alert');
   }
--- a/dom/browser-element/mochitest/browserElement_PromptConfirm.js
+++ b/dom/browser-element/mochitest/browserElement_PromptConfirm.js
@@ -10,17 +10,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   var prompts = [
     {msg: 1, type: 'alert', rv: 42, expected: 'undefined'},
     {msg: 2, type: 'confirm', rv: true, expected: 'true'},
     {msg: 3, type: 'confirm', rv: false, expected: 'false'},
 
     // rv == 42 should be coerced to 'true' for confirm.
--- a/dom/browser-element/mochitest/browserElement_PurgeHistory.js
+++ b/dom/browser-element/mochitest/browserElement_PurgeHistory.js
@@ -17,17 +17,17 @@ function addOneShotIframeEventListener(e
   iframe.addEventListener(event, wrapper);
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   addOneShotIframeEventListener('mozbrowserloadend', function() {
     SimpleTest.executeSoon(test2);
   });
 
   iframe.src = browserElementTestHelpers.emptyPage1;
   document.body.appendChild(iframe);
 }
--- a/dom/browser-element/mochitest/browserElement_Reload.js
+++ b/dom/browser-element/mochitest/browserElement_Reload.js
@@ -17,17 +17,17 @@ var iframe;
 var loadedEvents = 0;
 var countAcc;
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowserloadend', mozbrowserLoaded);
 
   iframe.src = 'file_bug741717.sjs';
   document.body.appendChild(iframe);
 }
 
 function iframeBodyRecv(data) {
--- a/dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
+++ b/dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
@@ -71,17 +71,17 @@ function pageLoadDone() {
   iframe.reload();
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   isPostRequestSubmitted = false;
   iframe.src = 'file_post_request.html';
   document.body.appendChild(iframe);
 
   iframe.addEventListener('mozbrowserloadend', pageLoadDone);
 
   let expectedMessage = getExpectedStrings();
--- a/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
+++ b/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
@@ -8,17 +8,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowsershowmodalprompt", function(e) {
     document.body.removeChild(iframe);
     SimpleTest.executeSoon(function() {
       ok(true);
       SimpleTest.finish();
     });
--- a/dom/browser-element/mochitest/browserElement_ScrollEvent.js
+++ b/dom/browser-element/mochitest/browserElement_ScrollEvent.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowserscroll", function(e) {
     ok(true, "got mozbrowserscroll event.");
     ok(e.detail, "event.detail is not null.");
     ok(e.detail.top === 4000, "top position is correct.");
     ok(e.detail.left === 4000, "left position is correct.");
     SimpleTest.finish();
--- a/dom/browser-element/mochitest/browserElement_SecurityChange.js
+++ b/dom/browser-element/mochitest/browserElement_SecurityChange.js
@@ -7,17 +7,17 @@
 "use strict";
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   var lastSecurityState;
   iframe.addEventListener('mozbrowsersecuritychange', function(e) {
     lastSecurityState = e.detail;
   });
 
   var filepath = 'tests/dom/browser-element/mochitest/file_browserElement_SecurityChange.html';
 
--- a/dom/browser-element/mochitest/browserElement_SendEvent.js
+++ b/dom/browser-element/mochitest/browserElement_SendEvent.js
@@ -6,17 +6,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement("iframe");
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowserloadend", function onloadend(e) {
     iframe.sendMouseEvent("mousedown", 10, 10, 0, 1, 0);
   });
 
   iframe.addEventListener("mozbrowserlocationchange", function onlocchange(e) {
     var a = document.createElement("a");
--- a/dom/browser-element/mochitest/browserElement_SetVisible.js
+++ b/dom/browser-element/mochitest/browserElement_SetVisible.js
@@ -17,17 +17,17 @@ var iframeScript = function() {
 function runTest() {
 
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var mm;
   var numEvents = 0;
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   iframe1.src = 'data:text/html,1';
 
   document.body.appendChild(iframe1);
 
   function recvVisibilityChanged(msg) {
     msg = SpecialPowers.wrap(msg);
     numEvents++;
     if (numEvents === 1) {
--- a/dom/browser-element/mochitest/browserElement_SetVisibleFrames.js
+++ b/dom/browser-element/mochitest/browserElement_SetVisibleFrames.js
@@ -19,17 +19,17 @@ function runTest() {
   browserElementTestHelpers.addPermission();
 
   var principal = SpecialPowers.wrap(SpecialPowers.getNodePrincipal(document));
   SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
                                                  appId: principal.appId,
                                                  isInBrowserElement: true });
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   // Our test involves three <iframe mozbrowser>'s, parent, child1, and child2.
   // child1 and child2 are contained inside parent.  child1 is visibile, and
   // child2 is not.
   //
   // For the purposes of this test, we want there to be a process barrier
   // between child{1,2} and parent.  Therefore parent must be a non-remote
   // <iframe mozbrowser>, until bug 761935 is resolved and we can have nested
--- a/dom/browser-element/mochitest/browserElement_SetVisibleFrames2.js
+++ b/dom/browser-element/mochitest/browserElement_SetVisibleFrames2.js
@@ -13,17 +13,17 @@ function runTest() {
   browserElementTestHelpers.addPermission();
 
   var principal = SpecialPowers.wrap(SpecialPowers.getNodePrincipal(document));
   SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec,
                                                  appId: principal.appId,
                                                  isInBrowserElement: true });
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   // We need remote = false here until bug 761935 is fixed; see
   // SetVisibleFrames.js for an explanation.
   iframe.remote = false;
 
   iframe.addEventListener('mozbrowserloadend', function loadEnd(e) {
     iframe.removeEventListener('mozbrowserloadend', loadEnd);
     iframe.setVisible(false);
--- a/dom/browser-element/mochitest/browserElement_Stop.js
+++ b/dom/browser-element/mochitest/browserElement_Stop.js
@@ -15,17 +15,17 @@ var iframe;
 var stopped = false;
 var imgSrc = 'http://test/tests/dom/browser-element/mochitest/file_bug709759.sjs';
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowserloadend', loadend);
   iframe.src = 'data:text/html,<html>' +
     '<body><img src="' + imgSrc + '" /></body></html>';
 
   document.body.appendChild(iframe);
 
   setTimeout(function() {
--- a/dom/browser-element/mochitest/browserElement_TargetBlank.js
+++ b/dom/browser-element/mochitest/browserElement_TargetBlank.js
@@ -7,17 +7,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     is(e.detail.url, 'http://example.com/');
     SimpleTest.finish();
   });
 
   iframe.src = "file_browserElement_TargetBlank.html";
   document.body.appendChild(iframe);
--- a/dom/browser-element/mochitest/browserElement_TargetTop.js
+++ b/dom/browser-element/mochitest/browserElement_TargetTop.js
@@ -7,17 +7,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   iframe.addEventListener('mozbrowseropenwindow', function(e) {
     ok(false, 'Not expecting an openwindow event.');
   });
 
   iframe.addEventListener('mozbrowserlocationchange', function(e) {
     if (/file_browserElement_TargetTop.html\?2$/.test(e.detail)) {
       ok(true, 'Got the locationchange we were looking for.');
--- a/dom/browser-element/mochitest/browserElement_Titlechange.js
+++ b/dom/browser-element/mochitest/browserElement_Titlechange.js
@@ -6,24 +6,24 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
+  SpecialPowers.wrap(iframe1).mozbrowser = true;
   document.body.appendChild(iframe1);
 
   // iframe2 is a red herring; we modify its title but don't listen for
   // titlechanges; we want to make sure that its titlechange events aren't
   // picked up by the listener on iframe1.
   var iframe2 = document.createElement('iframe');
-  iframe2.mozbrowser = true;
+  SpecialPowers.wrap(iframe2).mozbrowser = true;
   document.body.appendChild(iframe2);
 
   // iframe3 is another red herring.  It's not a mozbrowser, so we shouldn't
   // get any titlechange events on it.
   var iframe3 = document.createElement('iframe');
   document.body.appendChild(iframe3);
 
   var numTitleChanges = 0;
--- a/dom/browser-element/mochitest/browserElement_TopBarrier.js
+++ b/dom/browser-element/mochitest/browserElement_TopBarrier.js
@@ -12,17 +12,17 @@ function runTest() {
   iframe = document.createElement('iframe');
   iframe.addEventListener('mozbrowserloadend', function() {
     try {
       outerIframeLoaded();
     } catch(e) {
       dump("Got error: " + e + '\n');
     }
   });
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.src = 'data:text/html,Outer iframe <iframe id="inner-iframe"></iframe>';
   // For kicks, this test uses a display:none iframe.  This shouldn't make a
   // difference in anything.
   iframe.style.display = 'none';
   document.body.appendChild(iframe);
 
   SimpleTest.waitForExplicitFinish();
 }
--- a/dom/browser-element/mochitest/browserElement_XFrameOptions.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptions.js
@@ -7,17 +7,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   // The page we load will fire an alert when it successfully loads.
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     ok(true, "Got alert");
     SimpleTest.finish();
   });
 
   document.body.appendChild(iframe);
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
@@ -25,17 +25,17 @@ function arrayBuffersEqual(a, b) {
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
   var count = 0;
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   iframe.height = '1000px';
 
   // The innermost page we load will fire an alert when it successfully loads.
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     switch (e.detail.message) {
     case 'step 1':
       // Make the page wait for us to unblock it (which we do after we finish
       // taking the screenshot).
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
@@ -25,17 +25,17 @@ function arrayBuffersEqual(a, b) {
   return true;
 }
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   // Our child will create two iframes, so make sure this iframe is big enough
   // to show both of them without scrolling, so taking a screenshot gets both
   // frames.
   iframe.height = '1000px';
 
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     switch (e.detail.message) {
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
@@ -9,17 +9,17 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermission();
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
 
   // The innermost page we load will fire an alert when it successfully loads.
   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
     ok(true, "Got alert");
     SimpleTest.finish();
   });
 
   document.body.appendChild(iframe);
--- a/dom/browser-element/mochitest/createNewTest.py
+++ b/dom/browser-element/mochitest/createNewTest.py
@@ -36,17 +36,17 @@ js_template = textwrap.dedent("""\
 
     SimpleTest.waitForExplicitFinish();
 
     function runTest() {{
       browserElementTestHelpers.setEnabledPref(true);
       browserElementTestHelpers.addPermission();
 
       var iframe = document.createElement('iframe');
-      iframe.mozbrowser = true;
+      SpecialPowers.wrap(iframe).mozbrowser = true;
 
       // FILL IN TEST
 
       document.body.appendChild(iframe);
     }}
 
     runTest();""")
 
--- a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html
+++ b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html
@@ -1,14 +1,14 @@
 <html>
 <body>
 <script>
 
 var iframe = document.createElement('iframe');
-iframe.mozbrowser = true;
+iframe.setAttribute("mozbrowser", "true");
 
 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
   if (e.detail.message == 'child:ready') {
     setTimeout(function() {
       iframe.setVisible(false);
       iframe.setVisible(true);
       setTimeout(function() {
         alert('parent:finish');
--- a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames_Outer.html
+++ b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames_Outer.html
@@ -22,21 +22,21 @@ function handlePrompt(e) {
     alert('parent:ready');
   }
   else if (numPrompts == 4 || numPrompts == 5) {
     alert(e.detail.message);
   }
 }
 
 var iframe1 = document.createElement('iframe');
-iframe1.mozbrowser = true;
+iframe1.setAttribute("mozbrowser", "true");
 iframe1.addEventListener('mozbrowsershowmodalprompt', handlePrompt);
 
 var iframe2 = document.createElement('iframe');
-iframe2.mozbrowser = true;
+iframe2.setAttribute("mozbrowser", "true");
 iframe2.addEventListener('mozbrowsershowmodalprompt', handlePrompt);
 
 iframe1.src = 'file_browserElement_SetVisibleFrames_Inner.html?child1';
 iframe2.src = 'file_browserElement_SetVisibleFrames_Inner.html?child2';
 document.body.appendChild(iframe1);
 document.body.appendChild(iframe2);
 
 </script>
--- a/dom/browser-element/mochitest/test_browserElement_NoPref.html
+++ b/dom/browser-element/mochitest/test_browserElement_NoPref.html
@@ -21,17 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(false);
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener('mozbrowserloadstart', function() {
     ok(false, 'Should not send mozbrowserloadstart event.');
   });
 
   iframe.addEventListener('load', function() {
     ok(true, 'Got iframe load event.');
--- a/dom/browser-element/mochitest/test_browserElement_NoWhitelist.html
+++ b/dom/browser-element/mochitest/test_browserElement_NoWhitelist.html
@@ -22,17 +22,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
   browserElementTestHelpers.setEnabledPref(true);
   browserElementTestHelpers.addPermissionForUrl('http://foobar.com');
 
   var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
+  SpecialPowers.wrap(iframe).mozbrowser = true;
   document.body.appendChild(iframe);
 
   iframe.addEventListener('mozbrowserloadstart', function() {
     ok(false, 'Should not send mozbrowserloadstart event.');
   });
 
   iframe.addEventListener('load', function() {
     ok(true, 'Got iframe load event.');
--- a/dom/devicestorage/ipc/test_ipc.html
+++ b/dom/devicestorage/ipc/test_ipc.html
@@ -84,17 +84,17 @@
       mm.removeMessageListener("test:DeviceStorage:ipcTestMessage", onTestMessage);
       mm.removeMessageListener("test:DeviceStorage:ipcTestComplete", onTestComplete);
 
       SimpleTest.executeSoon(function () { SimpleTest.finish(); });
     }
 
     function runTests() {
       let iframe = document.createElement("iframe");
-      iframe.mozbrowser = true;
+      SpecialPowers.wrap(iframe).mozbrowser = true;
       iframe.id = "iframe";
       iframe.style.width = "100%";
       iframe.style.height = "1000px";
 
       function iframeLoadSecond() {
         ok(true, "Got second iframe load event.");
         iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond);
         let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
--- a/dom/indexedDB/ipc/test_ipc.html
+++ b/dom/indexedDB/ipc/test_ipc.html
@@ -103,17 +103,17 @@
       is(usingChildProcess, true, "Expecting to run in child process");
       is(seenTestMessage, true, "Expecting to receive messages from child");
       SpecialPowers.removePermission("browser", window.location.href);
       SimpleTest.executeSoon(function () { SimpleTest.finish(); });
     }
 
     function runTests() {
       let iframe = document.createElement("iframe");
-      iframe.mozbrowser = true;
+      SpecialPowers.wrap(iframe).mozbrowser = true;
       iframe.id = "iframe";
       iframe.style.width = "100%";
       iframe.style.height = "1000px";
 
       function iframeLoadSecond() {
         ok(true, "Got second iframe load event.");
         iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond);
         let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
--- a/layout/base/tests/test_remote_frame.html
+++ b/layout/base/tests/test_remote_frame.html
@@ -38,17 +38,17 @@
         todo(false, "We couldn't draw the frame, but at least we didn't crash");
         SimpleTest.finish();
         return;
       }
       setTimeout(pollForTestPass, 10);
     }
     function addRemoteFrame() {
       let iframe = document.createElement("iframe");
-      iframe.mozbrowser = true;
+      SpecialPowers.wrap(iframe).mozbrowser = true;
       iframe.src = "data:text/html,<html style='background:blue;'>";
 
       document.body.appendChild(iframe);
 
       pollForTestPass();
     }
     addEventListener("load", function() {
       referenceSnapshot = snapshotWindow(window);