Bug 736688 - Part 2: Move browser frame tests to their own directory. r=smaug
authorJustin Lebar <justin.lebar@gmail.com>
Wed, 28 Mar 2012 11:36:03 -0700
changeset 93863 e69f1c7562aa9b5eea20b976dad20e7abafdba3e
parent 93862 8e1f2165d52ec92e8d350ed66867c7fdff395a3f
child 93864 3e8f54937d3b9ea54afd81e23f8c4257fb8bf96d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs736688
milestone14.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 736688 - Part 2: Move browser frame tests to their own directory. r=smaug
dom/tests/mochitest/Makefile.in
dom/tests/mochitest/browser-frame/Makefile.in
dom/tests/mochitest/browser-frame/browserFrameHelpers.js
dom/tests/mochitest/browser-frame/test_browserFrame1.html
dom/tests/mochitest/browser-frame/test_browserFrame2.html
dom/tests/mochitest/browser-frame/test_browserFrame3.html
dom/tests/mochitest/browser-frame/test_browserFrame4.html
dom/tests/mochitest/browser-frame/test_browserFrame5.html
dom/tests/mochitest/browser-frame/test_browserFrame6.html
dom/tests/mochitest/browser-frame/test_browserFrame7.html
dom/tests/mochitest/general/Makefile.in
dom/tests/mochitest/general/browserFrameHelpers.js
dom/tests/mochitest/general/test_browserFrame1.html
dom/tests/mochitest/general/test_browserFrame2.html
dom/tests/mochitest/general/test_browserFrame3.html
dom/tests/mochitest/general/test_browserFrame4.html
dom/tests/mochitest/general/test_browserFrame5.html
dom/tests/mochitest/general/test_browserFrame6.html
dom/tests/mochitest/general/test_browserFrame7.html
--- a/dom/tests/mochitest/Makefile.in
+++ b/dom/tests/mochitest/Makefile.in
@@ -52,16 +52,17 @@ DIRS	+= \
 	chrome \
 	general \
 	whatwg \
 	geolocation \
 	localstorage \
 	orientation \
 	sessionstorage \
 	storageevent \
+	browser-frame \
 	$(NULL)
 
 #needs IPC support, also tests do not run successfully in Firefox for now
 #ifneq (mobile,$(MOZ_BUILD_APP))
 #DIRS	+= notification
 #endif
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/Makefile.in
@@ -0,0 +1,59 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2007
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ../../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+relativesrcdir  = dom/tests/mochitest/browser-frame
+
+include $(DEPTH)/config/autoconf.mk
+include $(topsrcdir)/config/rules.mk
+
+_TEST_FILES = \
+		browserFrameHelpers.js \
+		test_browserFrame1.html \
+		test_browserFrame2.html \
+		test_browserFrame3.html \
+		test_browserFrame4.html \
+		test_browserFrame5.html \
+		test_browserFrame6.html \
+		test_browserFrame7.html \
+		$(NULL)
+
+libs:: $(_TEST_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/browserFrameHelpers.js
@@ -0,0 +1,62 @@
+"use strict";
+
+// Helpers for managing the browser frame preferences.
+
+const browserFrameHelpers = {
+  'getEnabledPref': function() {
+    try {
+      return SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
+    }
+    catch(e) {
+      return undefined;
+    }
+  },
+
+  'getWhitelistPref': function() {
+    try {
+      return SpecialPowers.getCharPref('dom.mozBrowserFramesWhitelist');
+    }
+    catch(e) {
+      return undefined;
+    }
+  },
+
+  'setEnabledPref': function(enabled) {
+    if (enabled !== undefined) {
+      SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', enabled);
+    }
+    else {
+      SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
+    }
+  },
+
+  'setWhitelistPref': function(whitelist) {
+    if (whitelist !== undefined) {
+      SpecialPowers.setCharPref('dom.mozBrowserFramesWhitelist', whitelist);
+    }
+    else {
+      SpecialPowers.clearUserPref('dom.mozBrowserFramesWhitelist');
+    }
+  },
+
+  'addToWhitelist': function() {
+    var whitelist = browserFrameHelpers.getWhitelistPref();
+    whitelist += ',  http://' + window.location.host + ',  ';
+    browserFrameHelpers.setWhitelistPref(whitelist);
+  },
+
+  'restoreOriginalPrefs': function() {
+    browserFrameHelpers.setEnabledPref(browserFrameHelpers.origEnabledPref);
+    browserFrameHelpers.setWhitelistPref(browserFrameHelpers.origWhitelistPref);
+  },
+
+  'origEnabledPref': null,
+  'origWhitelistPref': null
+};
+
+browserFrameHelpers.origEnabledPref = browserFrameHelpers.getEnabledPref();
+browserFrameHelpers.origWhitelistPref = browserFrameHelpers.getWhitelistPref();
+
+addEventListener('unload', function() {
+  browserFrameHelpers.restoreOriginalPrefs();
+});
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame1.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=710231
+-->
+<head>
+  <title>Test for Bug 710231</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
+
+<!--
+  Test that an iframe without the |mozbrowser| attribute does not emit
+  mozbrowserX events.
+-->
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  var iframe = document.getElementById('iframe');
+  iframe.addEventListener('mozbrowserloadstart', function() {
+    ok(false, 'Should not send mozbrowserloadstart event.');
+  });
+
+  iframe.addEventListener('load', function() {
+    ok(true, 'Got iframe load event.');
+    SimpleTest.finish();
+  });
+
+  iframe.src = 'http://example.com';
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+<iframe id='iframe'></iframe>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame2.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=710231
+-->
+<head>
+  <title>Test for Bug 710231</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
+
+<!--
+  Test that an iframe with the |mozbrowser| attribute does not emit
+  mozbrowserX events when they're globally pref'ed off.
+-->
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserFrameHelpers.setEnabledPref(false);
+
+  var iframe = document.createElement('iframe');
+  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.');
+    SimpleTest.finish();
+  });
+
+  iframe.src = 'http://example.com';
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame3.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=710231
+-->
+<head>
+  <title>Test for Bug 710231</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
+
+<!--
+  Test that an iframe with the |mozbrowser| attribute does not emit
+  mozbrowserX events when this page is not in the whitelist.
+-->
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserFrameHelpers.setEnabledPref(true);
+  browserFrameHelpers.setWhitelistPref(' http://foobar.com');
+
+  var iframe = document.createElement('iframe');
+  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.');
+    SimpleTest.finish();
+  });
+
+  iframe.src = 'http://example.com';
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame4.html
@@ -0,0 +1,156 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=710231
+-->
+<head>
+  <title>Test for Bug 710231</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
+
+<!--
+  Test that an iframe with the |mozbrowser| attribute emits
+  mozbrowserX events when this page is in the whitelist.
+-->
+
+<script type="application/javascript;version=1.7">
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserFrameHelpers.setEnabledPref(true);
+  browserFrameHelpers.addToWhitelist();
+
+  // Load example.org into the iframe, wait for that to finish loading, then
+  // call runTest2.
+  //
+  // This should trigger loadstart, load, and loadend events, but not a
+  // locationchange, because this is the initial load into the iframe.
+
+  var seenLoad = false;
+  var seenLoadEnd = false;
+  var seenLoadStart = false;
+
+  var iframe = document.createElement('iframe');
+  iframe.mozbrowser = true;
+  iframe.id = 'iframe';
+  iframe.src = 'http://example.org';
+
+  function loadstart(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!seenLoad, 'loadstart before load.');
+    ok(!seenLoadEnd, 'loadstart before loadend.');
+    ok(!seenLoadStart, 'Just one loadstart event.');
+    seenLoadStart = true;
+  }
+
+  function locationchange(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(false, 'Unexpected locationchange.');
+  }
+
+  function loadend(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(seenLoadStart, 'loadend after loadstart.');
+    ok(seenLoad, 'loadend after load.');
+    ok(!seenLoadEnd, 'Just one loadend event.');
+    seenLoadEnd = true;
+  }
+
+  function load(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(seenLoadStart, 'load after loadstart.');
+    ok(!seenLoad, 'Just one load event.');
+    ok(!seenLoadEnd, 'load before loadend.');
+    seenLoad = true;
+  }
+
+  iframe.addEventListener('mozbrowserloadstart', loadstart);
+  iframe.addEventListener('mozbrowserlocationchange', locationchange);
+  iframe.addEventListener('mozbrowserloadend', loadend);
+  iframe.addEventListener('load', load);
+
+  function waitForAllCallbacks() {
+    if (!seenLoadStart || !seenLoad || !seenLoadEnd) {
+      SimpleTest.executeSoon(waitForAllCallbacks);
+      return;
+    }
+
+    iframe.removeEventListener('mozbrowserloadstart', loadstart);
+    iframe.removeEventListener('mozbrowserlocationchange', locationchange);
+    iframe.removeEventListener('mozbrowserloadend', loadend);
+    iframe.removeEventListener('load', load);
+    runTest2();
+  }
+
+  document.body.appendChild(iframe);
+  waitForAllCallbacks();
+}
+
+function runTest2() {
+  var seenLoadStart = false;
+  var seenLoad = false;
+  var seenLoadEnd = false;
+  var seenLocationChange = false;
+
+  var iframe = document.getElementById('iframe');
+  iframe.addEventListener('mozbrowserloadstart', function(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!seenLoadStart, 'Just one loadstart event.');
+    seenLoadStart = true;
+    ok(!seenLoad, 'Got mozbrowserloadstart event before load.');
+    ok(!seenLoadEnd, 'Got mozbrowserloadstart before loadend.');
+    ok(!seenLocationChange, 'Got mozbrowserloadstart before locationchange.');
+  });
+
+  iframe.addEventListener('mozbrowserlocationchange', function(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!seenLocationChange, 'Just one locationchange event.');
+    seenLocationChange = true;
+    ok(seenLoadStart, 'Location change after load start.');
+    ok(!seenLoad, 'Location change before load.');
+    ok(!seenLoadEnd, 'Location change before load end.');
+    ok(e.detail, 'http://example.com', "event's reported location");
+  });
+
+  iframe.addEventListener('load', function(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!seenLoad, 'Just one load event.');
+    seenLoad = true;
+    ok(seenLoadStart, 'Load after loadstart.');
+    ok(seenLocationChange, 'Load after locationchange.');
+    ok(!seenLoadEnd, 'Load before loadend.');
+  });
+
+  iframe.addEventListener('mozbrowserloadend', function(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!seenLoadEnd, 'Just one load end event.');
+    seenLoadEnd = true;
+    ok(seenLoadStart, 'Load end after load start.');
+    ok(seenLocationChange, 'Load end after location change.');
+  });
+
+  iframe.src = 'http://example.com';
+
+  function waitForAllCallbacks() {
+    if (!seenLoadStart || !seenLoad || !seenLoadEnd || !seenLocationChange) {
+      SimpleTest.executeSoon(waitForAllCallbacks);
+      return;
+    }
+
+    SimpleTest.finish();
+  }
+
+  waitForAllCallbacks();
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame5.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=720157
+-->
+<head>
+  <title>Test for Bug 720157</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720157">Mozilla Bug 720157</a>
+
+<!--
+  Test that data: URIs work with mozbrowserlocationchange events.
+-->
+
+<script type="application/javascript;version=1.7">
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserFrameHelpers.setEnabledPref(true);
+  browserFrameHelpers.addToWhitelist();
+
+  var iframe1 = document.createElement('iframe');
+  iframe1.mozbrowser = true;
+  iframe1.id = 'iframe1';
+  iframe1.addEventListener('load', function() {
+    iframe1.removeEventListener('load', arguments.callee);
+    SimpleTest.executeSoon(runTest2);
+  });
+  iframe1.src = 'http://example.org';
+  document.body.appendChild(iframe1);
+}
+
+function runTest2() {
+  var iframe1 = document.getElementById('iframe1');
+  var iframe2 = document.getElementById('iframe2');
+
+  var sawLoad = false;
+  var sawLocationChange = false;
+
+  iframe1.addEventListener('mozbrowserlocationchange', function(e) {
+    ok(e.isTrusted, 'Event should be trusted.');
+    ok(!sawLocationChange, 'Just one locationchange event.');
+    ok(!sawLoad, 'locationchange before load.');
+    is(e.detail, 'data:text/html,1', "event's reported location");
+    sawLocationChange = true;
+  });
+
+  iframe1.addEventListener('load', function() {
+    ok(sawLocationChange, 'Load after locationchange.');
+    ok(!sawLoad, 'Just one load event.');
+    sawLoad = true;
+  });
+
+  function iframe2Load() {
+    if (!sawLoad || !sawLocationChange) {
+      // Spin if iframe1 hasn't loaded yet.
+      SimpleTest.executeSoon(iframe2Load);
+      return;
+    }
+    ok(true, 'Got iframe2 load.');
+    SimpleTest.finish();
+  }
+  iframe2.addEventListener('load', iframe2Load);
+
+
+  iframe1.src = 'data:text/html,1';
+
+  // Load something into iframe2 to check that it doesn't trigger a
+  // locationchange for our iframe1 listener.
+  iframe2.src = 'http://example.com';
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+<iframe id='iframe2'></iframe>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame6.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=720157
+-->
+<head>
+  <title>Test for Bug 720157</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720157">Mozilla Bug 720157</a>
+
+<!--
+  Test that the onmozbrowsertitlechange event works.
+-->
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  browserFrameHelpers.setEnabledPref(true);
+  browserFrameHelpers.addToWhitelist();
+
+  var iframe1 = document.createElement('iframe');
+  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;
+  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;
+
+  iframe1.addEventListener('mozbrowsertitlechange', function(e) {
+    numTitleChanges++;
+
+    if (numTitleChanges == 1) {
+      is(e.detail, 'Title');
+      iframe1.contentDocument.title = 'New title';
+      iframe2.contentDocument.title = 'BAD TITLE 2';
+    }
+    else if (numTitleChanges == 2) {
+      is(e.detail, 'New title');
+      iframe1.src = 'data:text/html,<html><head><title>Title 3</title></head><body></body></html>';
+    }
+    else if (numTitleChanges == 3) {
+      is(e.detail, 'Title 3');
+      SimpleTest.finish();
+    }
+    else {
+      ok(false, 'Too many titlechange events.');
+    }
+  });
+
+  iframe3.addEventListener('mozbrowsertitlechange', function(e) {
+    ok(false, 'Should not get a titlechange event for iframe3.');
+  });
+
+  iframe1.src = 'data:text/html,<html><head><title>Title</title></head><body></body></html>';
+  iframe2.src = 'data:text/html,<html><head><title>BAD TITLE</title></head><body></body></html>';
+  iframe3.src = 'data:text/html,<html><head><title>SHOULD NOT GET EVENT</title></head><body></body></html>';
+}
+
+addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/browser-frame/test_browserFrame7.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=725796
+-->
+<head>
+  <title>Test for Bug 725796</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserFrameHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=725796">Mozilla Bug 725796</a>
+
+<!--
+  Test that an <iframe mozbrowser> is a window.{top,parent,frameElement} barrier.
+
+  If <iframe mozbrowser> is changed to run in a separate process, this test
+  will not work.
+-->
+
+<script type="application/javascript;version=1.7">
+"use strict";
+
+browserFrameHelpers.setEnabledPref(true);
+browserFrameHelpers.addToWhitelist();
+
+var iframe = document.createElement('iframe');
+iframe.addEventListener('load', function() {
+  outerIframeLoaded();
+});
+iframe.mozbrowser = true;
+iframe.src = 'data:text/html,Outer iframe';
+document.body.appendChild(iframe);
+
+SimpleTest.waitForExplicitFinish();
+
+function outerIframeLoaded() {
+  var innerIframe = iframe.contentDocument.createElement('iframe');
+  iframe.contentDocument.body.appendChild(innerIframe);
+
+  var iframeCw = iframe.contentWindow;
+  var innerCw = innerIframe.contentWindow;
+
+  is(iframeCw.top, iframeCw, 'iframe top');
+  is(iframeCw.parent, iframeCw, 'iframe parent');
+  is(iframeCw.frameElement, null, 'iframe frameElement');
+
+  is(innerCw.top, iframeCw, 'inner iframe top');
+  is(innerCw.parent, iframeCw, 'inner iframe parent');
+  is(innerCw.frameElement, innerIframe, 'inner iframe frameElement');
+  SimpleTest.finish();
+}
+
+</script>
+</body>
+</html>
--- a/dom/tests/mochitest/general/Makefile.in
+++ b/dom/tests/mochitest/general/Makefile.in
@@ -67,24 +67,16 @@ include $(topsrcdir)/config/rules.mk
 		test_clipboard_events.html \
 		test_frameElementWrapping.html \
 		file_frameElementWrapping.html \
 		test_framedhistoryframes.html \
 		test_windowedhistoryframes.html \
 		test_focusrings.xul \
 		file_moving_xhr.html \
 		test_vibrator.html \
-		browserFrameHelpers.js \
-		test_browserFrame1.html \
-		test_browserFrame2.html \
-		test_browserFrame3.html \
-		test_browserFrame4.html \
-		test_browserFrame5.html \
-		test_browserFrame6.html \
-		test_browserFrame7.html \
 		test_for_of.html \
 		test_focus_legend_noparent.html \
 		file_clonewrapper.html \
 		$(NULL)
 
 _CHROME_FILES = \
 		test_innerScreen.xul \
 		test_offsets.xul \
deleted file mode 100644
--- a/dom/tests/mochitest/general/browserFrameHelpers.js
+++ /dev/null
@@ -1,62 +0,0 @@
-"use strict";
-
-// Helpers for managing the browser frame preferences.
-
-const browserFrameHelpers = {
-  'getEnabledPref': function() {
-    try {
-      return SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
-    }
-    catch(e) {
-      return undefined;
-    }
-  },
-
-  'getWhitelistPref': function() {
-    try {
-      return SpecialPowers.getCharPref('dom.mozBrowserFramesWhitelist');
-    }
-    catch(e) {
-      return undefined;
-    }
-  },
-
-  'setEnabledPref': function(enabled) {
-    if (enabled !== undefined) {
-      SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', enabled);
-    }
-    else {
-      SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
-    }
-  },
-
-  'setWhitelistPref': function(whitelist) {
-    if (whitelist !== undefined) {
-      SpecialPowers.setCharPref('dom.mozBrowserFramesWhitelist', whitelist);
-    }
-    else {
-      SpecialPowers.clearUserPref('dom.mozBrowserFramesWhitelist');
-    }
-  },
-
-  'addToWhitelist': function() {
-    var whitelist = browserFrameHelpers.getWhitelistPref();
-    whitelist += ',  http://' + window.location.host + ',  ';
-    browserFrameHelpers.setWhitelistPref(whitelist);
-  },
-
-  'restoreOriginalPrefs': function() {
-    browserFrameHelpers.setEnabledPref(browserFrameHelpers.origEnabledPref);
-    browserFrameHelpers.setWhitelistPref(browserFrameHelpers.origWhitelistPref);
-  },
-
-  'origEnabledPref': null,
-  'origWhitelistPref': null
-};
-
-browserFrameHelpers.origEnabledPref = browserFrameHelpers.getEnabledPref();
-browserFrameHelpers.origWhitelistPref = browserFrameHelpers.getWhitelistPref();
-
-addEventListener('unload', function() {
-  browserFrameHelpers.restoreOriginalPrefs();
-});
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame1.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=710231
--->
-<head>
-  <title>Test for Bug 710231</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
-
-<!--
-  Test that an iframe without the |mozbrowser| attribute does not emit
-  mozbrowserX events.
--->
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  var iframe = document.getElementById('iframe');
-  iframe.addEventListener('mozbrowserloadstart', function() {
-    ok(false, 'Should not send mozbrowserloadstart event.');
-  });
-
-  iframe.addEventListener('load', function() {
-    ok(true, 'Got iframe load event.');
-    SimpleTest.finish();
-  });
-
-  iframe.src = 'http://example.com';
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-<iframe id='iframe'></iframe>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame2.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=710231
--->
-<head>
-  <title>Test for Bug 710231</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
-
-<!--
-  Test that an iframe with the |mozbrowser| attribute does not emit
-  mozbrowserX events when they're globally pref'ed off.
--->
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  browserFrameHelpers.setEnabledPref(false);
-
-  var iframe = document.createElement('iframe');
-  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.');
-    SimpleTest.finish();
-  });
-
-  iframe.src = 'http://example.com';
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame3.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=710231
--->
-<head>
-  <title>Test for Bug 710231</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
-
-<!--
-  Test that an iframe with the |mozbrowser| attribute does not emit
-  mozbrowserX events when this page is not in the whitelist.
--->
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  browserFrameHelpers.setEnabledPref(true);
-  browserFrameHelpers.setWhitelistPref(' http://foobar.com');
-
-  var iframe = document.createElement('iframe');
-  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.');
-    SimpleTest.finish();
-  });
-
-  iframe.src = 'http://example.com';
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame4.html
+++ /dev/null
@@ -1,156 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=710231
--->
-<head>
-  <title>Test for Bug 710231</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
-
-<!--
-  Test that an iframe with the |mozbrowser| attribute emits
-  mozbrowserX events when this page is in the whitelist.
--->
-
-<script type="application/javascript;version=1.7">
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  browserFrameHelpers.setEnabledPref(true);
-  browserFrameHelpers.addToWhitelist();
-
-  // Load example.org into the iframe, wait for that to finish loading, then
-  // call runTest2.
-  //
-  // This should trigger loadstart, load, and loadend events, but not a
-  // locationchange, because this is the initial load into the iframe.
-
-  var seenLoad = false;
-  var seenLoadEnd = false;
-  var seenLoadStart = false;
-
-  var iframe = document.createElement('iframe');
-  iframe.mozbrowser = true;
-  iframe.id = 'iframe';
-  iframe.src = 'http://example.org';
-
-  function loadstart(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!seenLoad, 'loadstart before load.');
-    ok(!seenLoadEnd, 'loadstart before loadend.');
-    ok(!seenLoadStart, 'Just one loadstart event.');
-    seenLoadStart = true;
-  }
-
-  function locationchange(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(false, 'Unexpected locationchange.');
-  }
-
-  function loadend(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(seenLoadStart, 'loadend after loadstart.');
-    ok(seenLoad, 'loadend after load.');
-    ok(!seenLoadEnd, 'Just one loadend event.');
-    seenLoadEnd = true;
-  }
-
-  function load(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(seenLoadStart, 'load after loadstart.');
-    ok(!seenLoad, 'Just one load event.');
-    ok(!seenLoadEnd, 'load before loadend.');
-    seenLoad = true;
-  }
-
-  iframe.addEventListener('mozbrowserloadstart', loadstart);
-  iframe.addEventListener('mozbrowserlocationchange', locationchange);
-  iframe.addEventListener('mozbrowserloadend', loadend);
-  iframe.addEventListener('load', load);
-
-  function waitForAllCallbacks() {
-    if (!seenLoadStart || !seenLoad || !seenLoadEnd) {
-      SimpleTest.executeSoon(waitForAllCallbacks);
-      return;
-    }
-
-    iframe.removeEventListener('mozbrowserloadstart', loadstart);
-    iframe.removeEventListener('mozbrowserlocationchange', locationchange);
-    iframe.removeEventListener('mozbrowserloadend', loadend);
-    iframe.removeEventListener('load', load);
-    runTest2();
-  }
-
-  document.body.appendChild(iframe);
-  waitForAllCallbacks();
-}
-
-function runTest2() {
-  var seenLoadStart = false;
-  var seenLoad = false;
-  var seenLoadEnd = false;
-  var seenLocationChange = false;
-
-  var iframe = document.getElementById('iframe');
-  iframe.addEventListener('mozbrowserloadstart', function(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!seenLoadStart, 'Just one loadstart event.');
-    seenLoadStart = true;
-    ok(!seenLoad, 'Got mozbrowserloadstart event before load.');
-    ok(!seenLoadEnd, 'Got mozbrowserloadstart before loadend.');
-    ok(!seenLocationChange, 'Got mozbrowserloadstart before locationchange.');
-  });
-
-  iframe.addEventListener('mozbrowserlocationchange', function(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!seenLocationChange, 'Just one locationchange event.');
-    seenLocationChange = true;
-    ok(seenLoadStart, 'Location change after load start.');
-    ok(!seenLoad, 'Location change before load.');
-    ok(!seenLoadEnd, 'Location change before load end.');
-    ok(e.detail, 'http://example.com', "event's reported location");
-  });
-
-  iframe.addEventListener('load', function(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!seenLoad, 'Just one load event.');
-    seenLoad = true;
-    ok(seenLoadStart, 'Load after loadstart.');
-    ok(seenLocationChange, 'Load after locationchange.');
-    ok(!seenLoadEnd, 'Load before loadend.');
-  });
-
-  iframe.addEventListener('mozbrowserloadend', function(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!seenLoadEnd, 'Just one load end event.');
-    seenLoadEnd = true;
-    ok(seenLoadStart, 'Load end after load start.');
-    ok(seenLocationChange, 'Load end after location change.');
-  });
-
-  iframe.src = 'http://example.com';
-
-  function waitForAllCallbacks() {
-    if (!seenLoadStart || !seenLoad || !seenLoadEnd || !seenLocationChange) {
-      SimpleTest.executeSoon(waitForAllCallbacks);
-      return;
-    }
-
-    SimpleTest.finish();
-  }
-
-  waitForAllCallbacks();
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame5.html
+++ /dev/null
@@ -1,85 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=720157
--->
-<head>
-  <title>Test for Bug 720157</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720157">Mozilla Bug 720157</a>
-
-<!--
-  Test that data: URIs work with mozbrowserlocationchange events.
--->
-
-<script type="application/javascript;version=1.7">
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  browserFrameHelpers.setEnabledPref(true);
-  browserFrameHelpers.addToWhitelist();
-
-  var iframe1 = document.createElement('iframe');
-  iframe1.mozbrowser = true;
-  iframe1.id = 'iframe1';
-  iframe1.addEventListener('load', function() {
-    iframe1.removeEventListener('load', arguments.callee);
-    SimpleTest.executeSoon(runTest2);
-  });
-  iframe1.src = 'http://example.org';
-  document.body.appendChild(iframe1);
-}
-  
-function runTest2() {
-  var iframe1 = document.getElementById('iframe1');
-  var iframe2 = document.getElementById('iframe2');
-
-  var sawLoad = false;
-  var sawLocationChange = false;
-
-  iframe1.addEventListener('mozbrowserlocationchange', function(e) {
-    ok(e.isTrusted, 'Event should be trusted.');
-    ok(!sawLocationChange, 'Just one locationchange event.');
-    ok(!sawLoad, 'locationchange before load.');
-    is(e.detail, 'data:text/html,1', "event's reported location");
-    sawLocationChange = true;
-  });
-
-  iframe1.addEventListener('load', function() {
-    ok(sawLocationChange, 'Load after locationchange.');
-    ok(!sawLoad, 'Just one load event.');
-    sawLoad = true;
-  });
-
-  function iframe2Load() {
-    if (!sawLoad || !sawLocationChange) {
-      // Spin if iframe1 hasn't loaded yet.
-      SimpleTest.executeSoon(iframe2Load);
-      return;
-    }
-    ok(true, 'Got iframe2 load.');
-    SimpleTest.finish();
-  }
-  iframe2.addEventListener('load', iframe2Load);
-
-
-  iframe1.src = 'data:text/html,1';
-
-  // Load something into iframe2 to check that it doesn't trigger a
-  // locationchange for our iframe1 listener.
-  iframe2.src = 'http://example.com';
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-<iframe id='iframe2'></iframe>
-
-</body>
-</html>
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame6.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=720157
--->
-<head>
-  <title>Test for Bug 720157</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=720157">Mozilla Bug 720157</a>
-
-<!--
-  Test that the onmozbrowsertitlechange event works.
--->
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-
-function runTest() {
-  browserFrameHelpers.setEnabledPref(true);
-  browserFrameHelpers.addToWhitelist();
-
-  var iframe1 = document.createElement('iframe');
-  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;
-  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;
-
-  iframe1.addEventListener('mozbrowsertitlechange', function(e) {
-    numTitleChanges++;
-
-    if (numTitleChanges == 1) {
-      is(e.detail, 'Title');
-      iframe1.contentDocument.title = 'New title';
-      iframe2.contentDocument.title = 'BAD TITLE 2';
-    }
-    else if (numTitleChanges == 2) {
-      is(e.detail, 'New title');
-      iframe1.src = 'data:text/html,<html><head><title>Title 3</title></head><body></body></html>';
-    }
-    else if (numTitleChanges == 3) {
-      is(e.detail, 'Title 3');
-      SimpleTest.finish();
-    }
-    else {
-      ok(false, 'Too many titlechange events.');
-    }
-  });
-
-  iframe3.addEventListener('mozbrowsertitlechange', function(e) {
-    ok(false, 'Should not get a titlechange event for iframe3.');
-  });
-
-  iframe1.src = 'data:text/html,<html><head><title>Title</title></head><body></body></html>';
-  iframe2.src = 'data:text/html,<html><head><title>BAD TITLE</title></head><body></body></html>';
-  iframe3.src = 'data:text/html,<html><head><title>SHOULD NOT GET EVENT</title></head><body></body></html>';
-}
-
-addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
-
-</script>
-
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/tests/mochitest/general/test_browserFrame7.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=725796
--->
-<head>
-  <title>Test for Bug 725796</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="browserFrameHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=725796">Mozilla Bug 725796</a>
-
-<!--
-  Test that an <iframe mozbrowser> is a window.{top,parent,frameElement} barrier.
-
-  If <iframe mozbrowser> is changed to run in a separate process, this test
-  will not work.
--->
-
-<script type="application/javascript;version=1.7">
-"use strict";
-
-browserFrameHelpers.setEnabledPref(true);
-browserFrameHelpers.addToWhitelist();
-
-var iframe = document.createElement('iframe');
-iframe.addEventListener('load', function() {
-  outerIframeLoaded();
-});
-iframe.mozbrowser = true;
-iframe.src = 'data:text/html,Outer iframe';
-document.body.appendChild(iframe);
-
-SimpleTest.waitForExplicitFinish();
-
-function outerIframeLoaded() {
-  var innerIframe = iframe.contentDocument.createElement('iframe');
-  iframe.contentDocument.body.appendChild(innerIframe);
-
-  var iframeCw = iframe.contentWindow;
-  var innerCw = innerIframe.contentWindow;
-
-  is(iframeCw.top, iframeCw, 'iframe top');
-  is(iframeCw.parent, iframeCw, 'iframe parent');
-  is(iframeCw.frameElement, null, 'iframe frameElement');
-
-  is(innerCw.top, iframeCw, 'inner iframe top');
-  is(innerCw.parent, iframeCw, 'inner iframe parent');
-  is(innerCw.frameElement, innerIframe, 'inner iframe frameElement');
-  SimpleTest.finish();
-}
-
-</script>
-</body>
-</html>