From 3ad459f0a7a9d19a93130f13cb8d9b7d49c76955 Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Thu, 4 Sep 2014 11:37:55 -0400 Subject: [PATCH] Backing out bug 961867 for causing an intermittent test failure. --- browser/base/content/browser.js | 33 ++++++++++++++++++- browser/base/content/content.js | 24 -------------- browser/base/content/tabbrowser.xml | 8 +++-- browser/base/content/test/general/browser.ini | 13 ++++++++ .../content/test/general/browser_bug575561.js | 24 +++++++++----- browser/base/content/test/general/head.js | 25 -------------- dom/interfaces/base/nsITabChild.idl | 3 -- dom/ipc/TabChild.cpp | 22 ------------- dom/ipc/TabChild.h | 2 -- .../mochitest/tests/SimpleTest/EventUtils.js | 6 ++-- toolkit/modules/BrowserUtils.jsm | 31 ----------------- 11 files changed, 69 insertions(+), 122 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index d07579831e02..359084887b37 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3543,11 +3543,42 @@ var XULBrowserWindow = { // Called before links are navigated to to allow us to retarget them if needed. onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) { - let target = BrowserUtils.onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab); + let target = this._onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab); SocialUI.closeSocialPanelForLinkTraversal(target, linkNode); return target; }, + _onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) { + // Don't modify non-default targets or targets that aren't in top-level app + // tab docshells (isAppTab will be false for app tab subframes). + if (originalTarget != "" || !isAppTab) + return originalTarget; + + // External links from within app tabs should always open in new tabs + // instead of replacing the app tab's page (Bug 575561) + let linkHost; + let docHost; + try { + linkHost = linkURI.host; + docHost = linkNode.ownerDocument.documentURIObject.host; + } catch(e) { + // nsIURI.host can throw for non-nsStandardURL nsIURIs. + // If we fail to get either host, just return originalTarget. + return originalTarget; + } + + if (docHost == linkHost) + return originalTarget; + + // Special case: ignore "www" prefix if it is part of host string + let [longHost, shortHost] = + linkHost.length > docHost.length ? [linkHost, docHost] : [docHost, linkHost]; + if (longHost == "www." + shortHost) + return originalTarget; + + return "_blank"; + }, + onProgressChange: function (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) { diff --git a/browser/base/content/content.js b/browser/base/content/content.js index 750ea6bc9dcb..deb6f8beb14a 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -660,27 +660,3 @@ Services.obs.addObserver(gKeywordURIFixup, "keyword-uri-fixup", false); addEventListener("unload", () => { Services.obs.removeObserver(gKeywordURIFixup, "keyword-uri-fixup"); }, false); - -addMessageListener("Browser:AppTab", function(message) { - docShell.isAppTab = message.data.isAppTab; -}); - -let WebBrowserChrome = { - onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) { - return BrowserUtils.onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab); - }, -}; - -if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) { - let tabchild = docShell.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsITabChild); - tabchild.webBrowserChrome = WebBrowserChrome; -} - -addEventListener("pageshow", function(event) { - if (event.target == content.document) { - sendAsyncMessage("PageVisibility:Show", { - persisted: event.persisted, - }); - } -}); diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 2c1af22e9b10..5f34233fbbba 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -289,7 +289,9 @@ this.tabContainer._positionPinnedTabs(); this.tabContainer.adjustTabstrip(); - this.getBrowserForTab(aTab).messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: true }) + // Bug 961867 - [e10s] Implement the logic for app tabs + if (!gMultiProcessBrowser) + this.getBrowserForTab(aTab).docShell.isAppTab = true; if (aTab.selected) this._setCloseKeyState(false); @@ -313,7 +315,9 @@ this.tabContainer._positionPinnedTabs(); this.tabContainer.adjustTabstrip(); - this.getBrowserForTab(aTab).messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: false }) + // Bug 961867 - [e10s] Implement the logic for app tabs + if (!gMultiProcessBrowser) + this.getBrowserForTab(aTab).docShell.isAppTab = false; if (aTab.selected) this._setCloseKeyState(true); diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 4f1de98d000d..c276b6d3222c 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -207,13 +207,17 @@ run-if = toolkit == "cocoa" [browser_bug567306.js] skip-if = e10s [browser_bug575561.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug575830.js] skip-if = e10s # Bug 691614 - no e10s zoom support yet [browser_bug577121.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug578534.js] skip-if = e10s # Bug ?????? - test directly manipulates content [browser_bug579872.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug580638.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug580956.js] skip-if = e10s # Bug 516755 - SessionStore disabled for e10s [browser_bug581242.js] @@ -223,16 +227,19 @@ skip-if = e10s # Bug 930863 - pageshow issues ("TypeError: charset is undefined" [browser_bug581947.js] skip-if = e10s [browser_bug585558.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug585785.js] [browser_bug585830.js] [browser_bug590206.js] [browser_bug592338.js] skip-if = e10s # Bug 653065 - Make the lightweight theme web installer ready for e10s [browser_bug594131.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug595507.js] skip-if = e10s # Bug 691601 - no form submit observers [browser_bug596687.js] [browser_bug597218.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_bug609700.js] skip-if = e10s # Bug 516755 - SessionStore disabled for e10s (calls duplicateTabIn, which uses SessionStore) [browser_bug623155.js] @@ -347,6 +354,7 @@ skip-if = buildapp == 'mulet' || e10s # Bug ?????? - uncaught exception - Error: [browser_offlineQuotaNotification.js] skip-if = buildapp == 'mulet' || e10s # Bug ?????? - test directly manipulates content (gBrowser.selectedBrowser.contentWindow.applicationCache.oncached = function() {...}) [browser_overflowScroll.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_pageInfo.js] skip-if = buildapp == 'mulet' || e10s # Bug 866413 - PageInfo doesn't work in e10s [browser_page_style_menu.js] @@ -358,6 +366,7 @@ skip-if = e10s skip-if = debug || asan # Times out on debug/asan, and we are less picky about our JS there [browser_pinnedTabs.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_plainTextLinks.js] skip-if = e10s # Bug ?????? - test directly manipulates content (creates and fetches elements directly from content document) [browser_popupUI.js] @@ -370,6 +379,7 @@ skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet' [browser_relatedTabs.js] [browser_removeTabsToTheEnd.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_removeUnsafeProtocolsFromURLBarPaste.js] skip-if = e10s [browser_sanitize-download-history.js] @@ -455,10 +465,13 @@ skip-if = e10s # Bug ?????? - FHR tests failing (either with "no data for today" skip-if = e10s # Bug ?????? - test directly manipulates content [browser_visibleLabel.js] [browser_visibleTabs.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_visibleTabs_bookmarkAllPages.js] skip-if = true # Bug 1005420 - fails intermittently. also with e10s enabled: bizarre problem with hidden tab having _mouseenter called, via _setPositionalAttributes, and tab not being found resulting in 'candidate is undefined' [browser_visibleTabs_bookmarkAllTabs.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_visibleTabs_contextMenu.js] +skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s [browser_visibleTabs_tabPreview.js] skip-if = (os == "win" && !debug) || e10s # Bug 1007418 / Bug 698371 - thumbnail captures need e10s love (tabPreviews_capture fails with Argument 1 of CanvasRenderingContext2D.drawWindow does not implement interface Window.) [browser_web_channel.js] diff --git a/browser/base/content/test/general/browser_bug575561.js b/browser/base/content/test/general/browser_bug575561.js index f9cd13dd9f7b..04bfcdb4c170 100644 --- a/browser/base/content/test/general/browser_bug575561.js +++ b/browser/base/content/test/general/browser_bug575561.js @@ -43,8 +43,16 @@ function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) { if (pinTab) gBrowser.pinTab(appTab); gBrowser.selectedTab = appTab; + appTab.linkedBrowser.addEventListener("load", onLoad, true); + + let loadCount = 0; + function onLoad() { + loadCount++; + if (loadCount < 2) + return; + + appTab.linkedBrowser.removeEventListener("load", onLoad, true); - waitForDocLoadComplete(appTab.linkedBrowser).then(function() { let browser = gBrowser.getBrowserForTab(appTab); if (testSubFrame) browser = browser.contentDocument.getElementsByTagName("iframe")[0]; @@ -54,7 +62,7 @@ function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) { if (expectNewTab) gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true); else - waitForDocLoadComplete(appTab.linkedBrowser).then(onPageLoad); + browser.addEventListener("load", onPageLoad, true); info("Clicking " + links[aLinkIndex].textContent); EventUtils.sendMouseEvent({type:"click"}, links[aLinkIndex], browser.contentWindow); @@ -72,13 +80,11 @@ function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) { function onTabOpen(event) { gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true); ok(true, "Link should open a new tab"); - waitForDocLoadComplete(event.target.linkedBrowser).then(function() { - executeSoon(function(){ - gBrowser.removeTab(appTab); - gBrowser.removeCurrentTab(); - nextTest(); - }); + executeSoon(function(){ + gBrowser.removeTab(appTab); + gBrowser.removeCurrentTab(); + nextTest(); }); } - }); + } } diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index ecc38d19915c..c8ee0f6b77f8 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -432,31 +432,6 @@ function waitForDocLoadAndStopIt(aExpectedURL, aBrowser=gBrowser.selectedBrowser }); } -/** - * Waits for the next load to complete in the current browser. - * - * @return promise - */ -function waitForDocLoadComplete(aBrowser=gBrowser) { - let deferred = Promise.defer(); - let progressListener = { - onStateChange: function (webProgress, req, flags, status) { - let docStart = Ci.nsIWebProgressListener.STATE_IS_NETWORK | - Ci.nsIWebProgressListener.STATE_STOP; - if ((flags & docStart) == docStart) { - aBrowser.removeProgressListener(progressListener); - info("Browser loaded"); - deferred.resolve(); - } - }, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, - Ci.nsISupportsWeakReference]) - }; - aBrowser.addProgressListener(progressListener); - info("Waiting for browser load"); - return deferred.promise; -} - let FullZoomHelper = { selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(tab) { diff --git a/dom/interfaces/base/nsITabChild.idl b/dom/interfaces/base/nsITabChild.idl index a8192795e91d..dd0d17d24958 100644 --- a/dom/interfaces/base/nsITabChild.idl +++ b/dom/interfaces/base/nsITabChild.idl @@ -5,15 +5,12 @@ #include "domstubs.idl" interface nsIContentFrameMessageManager; -interface nsIWebBrowserChrome3; [scriptable, uuid(2eb3bc54-78bf-40f2-b301-a5b5b70f7da0)] interface nsITabChild : nsISupports { readonly attribute nsIContentFrameMessageManager messageManager; - attribute nsIWebBrowserChrome3 webBrowserChrome; - [notxpcom] void sendRequestFocus(in boolean canFocus); }; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 792ce625f916..b066ad6a467a 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -80,7 +80,6 @@ #include "UnitTransforms.h" #include "ClientLayerManager.h" #include "LayersLogging.h" -#include "nsIWebBrowserChrome3.h" #include "nsColorPickerProxy.h" @@ -206,14 +205,12 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TabChildBase) NS_IMPL_CYCLE_COLLECTION_UNLINK(mTabChildGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK(mAnonymousGlobalScopes) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mWebBrowserChrome) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TabChildBase) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTabChildGlobal) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWebBrowserChrome) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(TabChildBase) @@ -1317,11 +1314,6 @@ TabChild::FocusPrevElement() NS_IMETHODIMP TabChild::GetInterface(const nsIID & aIID, void **aSink) { - if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome3))) { - NS_IF_ADDREF(((nsISupports *) (*aSink = mWebBrowserChrome))); - return NS_OK; - } - // XXXbz should we restrict the set of interfaces we hand out here? // See bug 537429 return QueryInterface(aIID, aSink); @@ -2848,20 +2840,6 @@ TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult) return NS_ERROR_FAILURE; } -NS_IMETHODIMP -TabChild::GetWebBrowserChrome(nsIWebBrowserChrome3** aWebBrowserChrome) -{ - NS_IF_ADDREF(*aWebBrowserChrome = mWebBrowserChrome); - return NS_OK; -} - -NS_IMETHODIMP -TabChild::SetWebBrowserChrome(nsIWebBrowserChrome3* aWebBrowserChrome) -{ - mWebBrowserChrome = aWebBrowserChrome; - return NS_OK; -} - void TabChild::SendRequestFocus(bool aCanFocus) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 939f6bee69a4..3a0f6494ea2c 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -33,7 +33,6 @@ #include "mozilla/EventDispatcher.h" #include "mozilla/EventForwards.h" #include "mozilla/layers/CompositorTypes.h" -#include "nsIWebBrowserChrome3.h" class nsICachedFileDescriptorListener; class nsIDOMWindowUtils; @@ -225,7 +224,6 @@ protected: ScreenIntSize mInnerSize; mozilla::layers::FrameMetrics mLastRootMetrics; mozilla::layout::ScrollingBehavior mScrolling; - nsCOMPtr mWebBrowserChrome; }; class TabChild MOZ_FINAL : public TabChildBase, diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index de8148a38d44..4702f8ae6c95 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -54,7 +54,7 @@ function sendMouseEvent(aEvent, aTarget, aWindow) { aWindow = window; } - if (typeof aTarget == "string") { + if (!(aTarget instanceof aWindow.Element)) { aTarget = aWindow.document.getElementById(aTarget); } @@ -974,8 +974,8 @@ function synthesizeText(aEvent, aWindow) const QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; const QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK = 0x0001; -const SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; -const SELECTION_SET_FLAG_USE_XP_LINE_BREAK = 0x0001; +const SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; +const SELECTION_SET_FLAG_USE_XP_LINE_BREAK = 0x0001; const SELECTION_SET_FLAG_REVERSE = 0x0002; /** diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index 2e4505b0922a..2157fe485c80 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -148,35 +148,4 @@ this.BrowserUtils = { win = element.contentDocument.defaultView; return { targetWindow: win, offsetX: offsetX, offsetY: offsetY }; }, - - onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) { - // Don't modify non-default targets or targets that aren't in top-level app - // tab docshells (isAppTab will be false for app tab subframes). - if (originalTarget != "" || !isAppTab) - return originalTarget; - - // External links from within app tabs should always open in new tabs - // instead of replacing the app tab's page (Bug 575561) - let linkHost; - let docHost; - try { - linkHost = linkURI.host; - docHost = linkNode.ownerDocument.documentURIObject.host; - } catch(e) { - // nsIURI.host can throw for non-nsStandardURL nsIURIs. - // If we fail to get either host, just return originalTarget. - return originalTarget; - } - - if (docHost == linkHost) - return originalTarget; - - // Special case: ignore "www" prefix if it is part of host string - let [longHost, shortHost] = - linkHost.length > docHost.length ? [linkHost, docHost] : [docHost, linkHost]; - if (longHost == "www." + shortHost) - return originalTarget; - - return "_blank"; - }, };