Merge m-c to inbound.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 11 Oct 2012 21:31:33 -0400
changeset 110138 3455c181525a0fa4dff66d8a31dc5054568c2e4e
parent 110137 c33c86c1a020a5eb95d751784dd41dd7c9073151 (current diff)
parent 110081 19cfc27b2c676298592f40fbcb4e5afb93bc4416 (diff)
child 110139 f31e2370284e6468e33e10ba19cbf06e05659073
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
milestone19.0a1
Merge m-c to inbound.
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_certexceptionsui.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_cookieacceptdialog.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_crh.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_localStorage.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_opendir.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_openlocation.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_placestitle.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_popupblocker.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_sslsite_transition.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_theming.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_ui.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_urlbarfocus.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js
browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoomrestore.js
browser/components/privatebrowsing/test/browser/global/head.js
browser/components/privatebrowsing/test/browser/global/title.sjs
browser/components/privatebrowsing/test/browser/obsolete/browser_console_clear.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_beforeunload.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_commandline_toggle.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_downloadmonitor.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_fastswitch.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_findbar.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_forgetthissite.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_import.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_newwindow_stopcmd.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_pageinfo.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_popupmode.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_searchbar.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_transition.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_urlbarundo.js
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js
browser/components/privatebrowsing/test/browser/obsolete/head.js
browser/components/privatebrowsing/test/browser/obsolete/staller.sjs
browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_lastpbcontextexited.js
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -1812,31 +1812,31 @@ nsINode::ReplaceOrInsertBefore(bool aRep
   }
 
   /*
    * Check if we're inserting a document fragment. If we are, we need
    * to actually add its children individually (i.e. we don't add the
    * actual document fragment).
    */
   if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
-    uint32_t count = fragChildren.ref().Length();
-    if (!count) {
-      return NS_OK;
-    }
-
     if (!aReplace) {
       mb.Init(this, true, true);
     }
     nsAutoMutationBatch* mutationBatch = nsAutoMutationBatch::GetCurrentBatch();
     if (mutationBatch) {
       mutationBatch->RemovalDone();
       mutationBatch->SetPrevSibling(GetChildAt(insPos - 1));
       mutationBatch->SetNextSibling(GetChildAt(insPos));
     }
 
+    uint32_t count = fragChildren.ref().Length();
+    if (!count) {
+      return NS_OK;
+    }
+
     bool appending =
       !IsNodeOfType(eDOCUMENT) && uint32_t(insPos) == GetChildCount();
     int32_t firstInsPos = insPos;
     nsIContent* firstInsertedContent = fragChildren.ref().ElementAt(0);
 
     // Iterate through the fragment's children, and insert them in the new
     // parent
     for (uint32_t i = 0; i < count; ++i, ++insPos) {
--- a/content/base/test/test_mutationobservers.html
+++ b/content/base/test/test_mutationobservers.html
@@ -311,16 +311,17 @@ function testChildList5() {
   div.textContent = null;
   var c1 = div.appendChild(document.createElement("div"));
   var c2 = document.createElement("div");
   var div2 = document.createElement("div");
   var c3 = div2.appendChild(document.createElement("div"));
   var c4 = document.createElement("div");
   var c5 = document.createElement("div");
   var df = document.createDocumentFragment();
+  var emptyDF = document.createDocumentFragment();
   var dfc1 = df.appendChild(document.createElement("div"));
   var dfc2 = df.appendChild(document.createElement("div"));
   var dfc3 = df.appendChild(document.createElement("div"));
   m = new M(function(records, observer) {
       is(records.length, 6 , "");
       is(records[0].removedNodes.length, 1, "Should have got removedNodes");
       is(records[0].removedNodes[0], c1, "");
       is(records[0].addedNodes.length, 1, "Should have got addedNodes");
@@ -353,16 +354,17 @@ function testChildList5() {
     });
   m.observe(div, { childList: true, subtree: true });
   m.observe(div2, { childList: true, subtree: true });
   div.replaceChild(c2, c1);
   div.replaceChild(c3, c2);
   div.appendChild(c4);
   div.appendChild(c5);
   div.replaceChild(df, c4);
+  div.appendChild(emptyDF); // empty document shouldn't cause mutation records
 }
 
 function testAdoptNode() {
   var d1 = document.implementation.createHTMLDocument(null);
   var d2 = document.implementation.createHTMLDocument(null);
   var addedNode;
   m = new M(function(records, observer) {
       is(records.length, 3, "Should have 2 records");
@@ -380,38 +382,44 @@ function testAdoptNode() {
   addedNode.setAttribute("foo", "bar");
 }
 
 function testOuterHTML() {
   var doc = document.implementation.createHTMLDocument(null);
   var d1 = doc.body.appendChild(document.createElement("div"));
   var d2 = doc.body.appendChild(document.createElement("div"));
   var d3 = doc.body.appendChild(document.createElement("div"));
+  var d4 = doc.body.appendChild(document.createElement("div"));
   m = new M(function(records, observer) {
-      is(records.length, 3, "Should have 1 record");
+      is(records.length, 4, "Should have 1 record");
       is(records[0].removedNodes.length, 1, "Should have 1 removed nodes");
       is(records[0].addedNodes.length, 2, "Should have 2 added nodes");
       is(records[0].previousSibling, null, "");
       is(records[0].nextSibling, d2, "");
       is(records[1].removedNodes.length, 1, "Should have 1 removed nodes");
       is(records[1].addedNodes.length, 2, "Should have 2 added nodes");
       is(records[1].previousSibling, records[0].addedNodes[1], "");
       is(records[1].nextSibling, d3, "");
       is(records[2].removedNodes.length, 1, "Should have 1 removed nodes");
       is(records[2].addedNodes.length, 2, "Should have 2 added nodes");
       is(records[2].previousSibling, records[1].addedNodes[1], "");
-      is(records[2].nextSibling, null, "");
+      is(records[2].nextSibling, d4, "");
+      is(records[3].removedNodes.length, 1, "Should have 1 removed nodes");
+      is(records[3].addedNodes.length, 0);
+      is(records[3].previousSibling, records[2].addedNodes[1], "");
+      is(records[3].nextSibling, null, "");
       observer.disconnect();
       then(testInsertAdjacentHTML);
       m = null;
     });
   m.observe(doc, { childList: true, subtree: true });
   d1.outerHTML = "<div>1</div><div>1</div>";
   d2.outerHTML = "<div>2</div><div>2</div>";
   d3.outerHTML = "<div>3</div><div>3</div>";
+  d4.outerHTML = "";
 }
 
 function testInsertAdjacentHTML() {
   var doc = document.implementation.createHTMLDocument(null);
   var d1 = doc.body.appendChild(document.createElement("div"));
   var d2 = doc.body.appendChild(document.createElement("div"));
   var d3 = doc.body.appendChild(document.createElement("div"));
   var d4 = doc.body.appendChild(document.createElement("div"));
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -3252,21 +3252,27 @@ nsEventStateManager::PostHandleEvent(nsP
         // When the event was cancelled, there is currently a chrome document
         // focused and a mousedown just occurred on a content document, ensure
         // that the window that was clicked is focused.
         EnsureDocument(mPresContext);
         nsIFocusManager* fm = nsFocusManager::GetFocusManager();
         if (mDocument && fm) {
           nsCOMPtr<nsIDOMWindow> currentWindow;
           fm->GetFocusedWindow(getter_AddRefs(currentWindow));
-          if (currentWindow && currentWindow != mDocument->GetWindow() &&
+          if (currentWindow && mDocument->GetWindow() &&
+              currentWindow != mDocument->GetWindow() &&
               !nsContentUtils::IsChromeDoc(mDocument)) {
+            nsCOMPtr<nsIDOMWindow> currentTop;
+            nsCOMPtr<nsIDOMWindow> newTop;
+            currentWindow->GetScriptableTop(getter_AddRefs(currentTop));
+            mDocument->GetWindow()->GetScriptableTop(getter_AddRefs(newTop));
             nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(currentWindow);
             nsCOMPtr<nsIDocument> currentDoc = do_QueryInterface(win->GetExtantDocument());
-            if (nsContentUtils::IsChromeDoc(currentDoc)) {
+            if (nsContentUtils::IsChromeDoc(currentDoc) ||
+                (currentTop && newTop && currentTop != newTop)) {
               fm->SetFocusedWindow(mDocument->GetWindow());
             }
           }
         }
       }
       SetActiveManager(this, activeContent);
     }
     break;
--- a/dom/tests/mochitest/chrome/Makefile.in
+++ b/dom/tests/mochitest/chrome/Makefile.in
@@ -43,16 +43,18 @@ MOCHITEST_CHROME_FILES = \
 		test_clonewrapper.xul \
 		test_moving_nodeList.xul \
 		test_callback_wrapping.xul \
 		window_callback_wrapping.xul \
 		test_sandbox_postMessage.html \
 		test_sandbox_bindings.xul \
 		test_selectAtPoint.html \
 		selectAtPoint.html \
+		test_bug799299.xul \
+		file_bug799299.xul \
 		$(NULL)
 
 ifeq (WINNT,$(OS_ARCH))
 MOCHITEST_CHROME_FILES += \
 		test_sizemode_attribute.xul \
 		sizemode_attribute.xul \
 		$(NULL)
 endif
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/chrome/file_bug799299.xul
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=799299
+-->
+<window title="Mozilla Bug 799299"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=799299"
+     target="_blank">Mozilla Bug 799299</a>
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+  /** Test for Bug 799299 **/
+
+  function sendClick(win) {
+    var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                .getInterface(Components.interfaces.nsIDOMWindowUtils);
+    wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
+    wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
+  }
+
+  function runTests() {
+    var b1 = document.getElementById("b1");
+    var b2 = document.getElementById("b2");
+    b1.contentWindow.focus();
+    opener.wrappedJSObject.is(document.activeElement, b1);
+
+    var didCallDummy = false;
+    b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
+    sendClick(b2.contentWindow);
+    opener.wrappedJSObject.ok(didCallDummy);
+    opener.wrappedJSObject.is(document.activeElement, b2);
+
+    b1.contentWindow.focus();
+    opener.wrappedJSObject.is(document.activeElement, b1);
+
+    var didCallListener = false;
+    b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
+    sendClick(b2.contentWindow);
+    opener.wrappedJSObject.ok(didCallListener);
+    opener.wrappedJSObject.is(document.activeElement, b2);
+
+    window.close();
+    opener.wrappedJSObject.SimpleTest.finish();
+  }
+
+  SimpleTest.waitForFocus(runTests);
+  ]]>
+  </script>
+  <hbox flex="1">
+    <browser id="b1" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
+    <browser id="b2" type="content" src="about:blank" flex="1" style="border: 1px solid black;"/>
+  </hbox>
+</window>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/chrome/test_bug799299.xul
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=799299
+-->
+<window title="Mozilla Bug 799299" onload="runTests()"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
+
+  <!-- test results are displayed in the html:body -->
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=799299"
+     target="_blank">Mozilla Bug 799299</a>
+  </body>
+
+  <!-- test code goes here -->
+  <script type="application/javascript">
+  <![CDATA[
+  /** Test for Bug 799299 **/
+
+  function runTests() {
+    window.open("file_bug799299.xul", "_blank", "chrome,width=600,height=550");
+  }
+
+  SimpleTest.waitForExplicitFinish();
+
+  ]]>
+  </script>
+</window>
--- a/python/mach/mach/mixin/process.py
+++ b/python/mach/mach/mixin/process.py
@@ -118,8 +118,9 @@ class ProcessExecutionMixin(LoggingMixin
 
         # PyMake removes the C: prefix. But, things seem to work here
         # without it. Not sure what that's about.
 
         # We run everything through the msys shell. We need to use
         # '-c' and pass all the arguments as one argument because that is
         # how sh works.
         cline = subprocess.list2cmdline([prog] + args[1:])
+        return [_current_shell, '-c', cline]
--- a/python/mozbuild/README.rst
+++ b/python/mozbuild/README.rst
@@ -5,10 +5,9 @@ mozbuild
 mozbuild is a Python package providing functionality used by Mozilla's
 build system.
 
 Modules Overview
 ================
 
 * mozbuild.compilation -- Functionality related to compiling. This
   includes managing compiler warnings.
-* mozbuild.testing -- Interfaces for running tests.
 
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -262,18 +262,16 @@ class MozbuildObject(ProcessExecutionMix
         return self._make
 
     def _run_command_in_srcdir(self, **args):
         self.run_process(cwd=self.topsrcdir, **args)
 
     def _run_command_in_objdir(self, **args):
         self.run_process(cwd=self.topobjdir, **args)
 
-        return [_current_shell, '-c', cline]
-
     def _is_windows(self):
         return os.name in ('nt', 'ce')
 
     def _spawn(self, cls):
         """Create a new MozbuildObject-derived class instance from ourselves.
 
         This is used as a convenience method to create other
         MozbuildObject-derived class instances. It can only be used on
--- a/python/mozbuild/mozbuild/test/test_base.py
+++ b/python/mozbuild/mozbuild/test/test_base.py
@@ -4,41 +4,32 @@
 
 from __future__ import unicode_literals
 
 import os
 import unittest
 
 from tempfile import NamedTemporaryFile
 
-from mozbuild.base import BuildConfig
-from mozbuild.base import MozbuildObject
-from mozbuild.config import ConfigSettings
-from mozbuild.logger import LoggingManager
+from mach.logging import LoggingManager
+
+from mozbuild.base import (
+    BuildConfig,
+    MozbuildObject,
+)
 
 
 curdir = os.path.dirname(__file__)
 topsrcdir = os.path.normpath(os.path.join(curdir, '..', '..', '..', '..'))
 log_manager = LoggingManager()
 
 
-class TestBuildConfig(unittest.TestCase):
-    def test_basic(self):
-        c = ConfigSettings()
-        c.register_provider(BuildConfig)
-
-        c.build.threads = 6
-
-
 class TestMozbuildObject(unittest.TestCase):
     def get_base(self):
-        settings = ConfigSettings()
-        settings.register_provider(BuildConfig)
-
-        return MozbuildObject(topsrcdir, settings, log_manager)
+        return MozbuildObject(topsrcdir, None, log_manager)
 
     def test_mozconfig_parsing(self):
         with NamedTemporaryFile(mode='wt') as mozconfig:
             mozconfig.write('mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/some-objdir')
             mozconfig.flush()
 
             os.environ['MOZCONFIG'] = mozconfig.name
 
--- a/testing/marionette/client/marionette/emulator.py
+++ b/testing/marionette/client/marionette/emulator.py
@@ -328,16 +328,17 @@ class Emulator(object):
         Install gecko into the emulator using adb push.  Restart b2g after the
         installation.
         """
         if not self.gecko_path:
             return
         # need to remount so we can write to /system/b2g
         self._run_adb(['remount'])
         self._run_adb(['shell', 'stop', 'b2g'])
+        self._run_adb(['shell', 'rm', '-rf', '/system/b2g/*.so'])
         print 'installing gecko binaries'
         self._run_adb(['push', self.gecko_path, '/system/b2g'])
         print 'restarting B2G'
         self._run_adb(['shell', 'start', 'b2g'])
 
     def rotate_log(self, srclog, index=1):
         """ Rotate a logfile, by recursively rotating logs further in the sequence,
             deleting the last file if necessary.