зеркало из https://github.com/mozilla/gecko-dev.git
Bug 961867: Pass app tab status to child processes and allow onBeforeLinkTraversal to work there. r=smaug, r=felipe
This commit is contained in:
Родитель
9deba01d05
Коммит
0c740b5b4b
|
@ -3561,42 +3561,11 @@ var XULBrowserWindow = {
|
|||
|
||||
// Called before links are navigated to to allow us to retarget them if needed.
|
||||
onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) {
|
||||
let target = this._onBeforeLinkTraversal(originalTarget, linkURI, linkNode, isAppTab);
|
||||
let target = BrowserUtils.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) {
|
||||
|
|
|
@ -633,3 +633,19 @@ let DOMFullscreenHandler = {
|
|||
}
|
||||
};
|
||||
DOMFullscreenHandler.init();
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -289,9 +289,7 @@
|
|||
this.tabContainer._positionPinnedTabs();
|
||||
this.tabContainer.adjustTabstrip();
|
||||
|
||||
// Bug 961867 - [e10s] Implement the logic for app tabs
|
||||
if (!gMultiProcessBrowser)
|
||||
this.getBrowserForTab(aTab).docShell.isAppTab = true;
|
||||
this.getBrowserForTab(aTab).messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: true })
|
||||
|
||||
if (aTab.selected)
|
||||
this._setCloseKeyState(false);
|
||||
|
@ -315,9 +313,7 @@
|
|||
this.tabContainer._positionPinnedTabs();
|
||||
this.tabContainer.adjustTabstrip();
|
||||
|
||||
// Bug 961867 - [e10s] Implement the logic for app tabs
|
||||
if (!gMultiProcessBrowser)
|
||||
this.getBrowserForTab(aTab).docShell.isAppTab = false;
|
||||
this.getBrowserForTab(aTab).messageManager.sendAsyncMessage("Browser:AppTab", { isAppTab: false })
|
||||
|
||||
if (aTab.selected)
|
||||
this._setCloseKeyState(true);
|
||||
|
|
|
@ -198,17 +198,13 @@ skip-if = e10s # Bug 940195 - XULBrowserWindow.isBusy is false as a remote tab s
|
|||
run-if = toolkit == "cocoa"
|
||||
[browser_bug567306.js]
|
||||
[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]
|
||||
|
@ -217,19 +213,16 @@ skip-if = e10s # Bug 930863 - pageshow issues ("TypeError: charset is undefined"
|
|||
skip-if = e10s # Bug 930863 - pageshow issues ("TypeError: charset is undefined" in pageshow listener, as document is null)
|
||||
[browser_bug581947.js]
|
||||
[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]
|
||||
|
@ -336,7 +329,6 @@ 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]
|
||||
|
@ -347,7 +339,6 @@ skip-if = e10s # Bug ?????? - test directly manipulates content
|
|||
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]
|
||||
|
@ -360,7 +351,6 @@ 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]
|
||||
[browser_sanitize-download-history.js]
|
||||
skip-if = true # bug 432425
|
||||
|
@ -438,13 +428,10 @@ 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]
|
||||
|
|
|
@ -43,16 +43,8 @@ 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];
|
||||
|
@ -62,7 +54,7 @@ function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) {
|
|||
if (expectNewTab)
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true);
|
||||
else
|
||||
browser.addEventListener("load", onPageLoad, true);
|
||||
waitForDocLoadComplete(appTab.linkedBrowser).then(onPageLoad);
|
||||
|
||||
info("Clicking " + links[aLinkIndex].textContent);
|
||||
EventUtils.sendMouseEvent({type:"click"}, links[aLinkIndex], browser.contentWindow);
|
||||
|
@ -80,11 +72,13 @@ function testLink(aLinkIndex, pinTab, expectNewTab, nextTest, testSubFrame) {
|
|||
function onTabOpen(event) {
|
||||
gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true);
|
||||
ok(true, "Link should open a new tab");
|
||||
executeSoon(function(){
|
||||
gBrowser.removeTab(appTab);
|
||||
gBrowser.removeCurrentTab();
|
||||
nextTest();
|
||||
waitForDocLoadComplete(event.target.linkedBrowser).then(function() {
|
||||
executeSoon(function(){
|
||||
gBrowser.removeTab(appTab);
|
||||
gBrowser.removeCurrentTab();
|
||||
nextTest();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -417,6 +417,31 @@ function waitForDocLoadAndStopIt(aExpectedURL, aBrowser=gBrowser) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
|
||||
#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);
|
||||
};
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#include "UnitTransforms.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "LayersLogging.h"
|
||||
#include "nsIWebBrowserChrome3.h"
|
||||
|
||||
#include "nsColorPickerProxy.h"
|
||||
|
||||
|
@ -205,12 +206,14 @@ 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)
|
||||
|
@ -1314,6 +1317,11 @@ 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);
|
||||
|
@ -2840,6 +2848,20 @@ 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)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "nsIWebBrowserChrome3.h"
|
||||
|
||||
class nsICachedFileDescriptorListener;
|
||||
class nsIDOMWindowUtils;
|
||||
|
@ -224,6 +225,7 @@ protected:
|
|||
ScreenIntSize mInnerSize;
|
||||
mozilla::layers::FrameMetrics mLastRootMetrics;
|
||||
mozilla::layout::ScrollingBehavior mScrolling;
|
||||
nsCOMPtr<nsIWebBrowserChrome3> mWebBrowserChrome;
|
||||
};
|
||||
|
||||
class TabChild MOZ_FINAL : public TabChildBase,
|
||||
|
|
|
@ -54,7 +54,7 @@ function sendMouseEvent(aEvent, aTarget, aWindow) {
|
|||
aWindow = window;
|
||||
}
|
||||
|
||||
if (!(aTarget instanceof aWindow.Element)) {
|
||||
if (typeof aTarget == "string") {
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -148,4 +148,35 @@ 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";
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче