mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 21:58:41 +02:00
Bug 1344376 - Clicking on a link with target=_blank should fire onCreatedNavigationTarget. r=billm a=gchang
MozReview-Commit-ID: JVao8IuBz9B --HG-- extra : source : 7fc04ff18b6c9420ef1f6e848924beb389e13990
This commit is contained in:
parent
ba91b33caf
commit
1387211a0c
4 changed files with 50 additions and 1 deletions
|
|
@ -106,6 +106,22 @@ add_task(function* test_on_created_navigation_target_from_mouse_click() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
info("Open link with target=\"_blank\" in a new tab using click");
|
||||||
|
|
||||||
|
yield runTestCase({
|
||||||
|
extension,
|
||||||
|
openNavTarget() {
|
||||||
|
BrowserTestUtils.synthesizeMouseAtCenter("#test-create-new-tab-from-targetblank-click",
|
||||||
|
{},
|
||||||
|
tab.linkedBrowser);
|
||||||
|
},
|
||||||
|
expectedWebNavProps: {
|
||||||
|
sourceTabId: expectedSourceTab.sourceTabId,
|
||||||
|
sourceFrameId: 0,
|
||||||
|
url: `${OPENED_PAGE}#new-tab-from-targetblank-click`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
yield BrowserTestUtils.removeTab(tab);
|
yield BrowserTestUtils.removeTab(tab);
|
||||||
|
|
||||||
yield extension.unload();
|
yield extension.unload();
|
||||||
|
|
@ -216,6 +232,25 @@ add_task(function* test_on_created_navigation_target_from_mouse_click_subframe()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
info("Open a subframe link with target=\"_blank\" in a new tab using click");
|
||||||
|
|
||||||
|
yield runTestCase({
|
||||||
|
extension,
|
||||||
|
openNavTarget() {
|
||||||
|
BrowserTestUtils.synthesizeMouseAtCenter(function() {
|
||||||
|
// This code runs as a framescript in the child process and it returns the
|
||||||
|
// target link in the subframe.
|
||||||
|
return this.content.frames[0].document // eslint-disable-line mozilla/no-cpows-in-tests
|
||||||
|
.querySelector("#test-create-new-tab-from-targetblank-click-subframe");
|
||||||
|
}, {}, tab.linkedBrowser);
|
||||||
|
},
|
||||||
|
expectedWebNavProps: {
|
||||||
|
sourceTabId: expectedSourceTab.sourceTabId,
|
||||||
|
sourceFrameId: expectedSourceTab.sourceTabFrames[1].frameId,
|
||||||
|
url: `${OPENED_PAGE}#new-tab-from-targetblank-click-subframe`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
yield BrowserTestUtils.removeTab(tab);
|
yield BrowserTestUtils.removeTab(tab);
|
||||||
|
|
||||||
yield extension.unload();
|
yield extension.unload();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@
|
||||||
Open a target page in a new window from mouse click
|
Open a target page in a new window from mouse click
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a id="test-create-new-tab-from-targetblank-click"
|
||||||
|
href="webNav_createdTarget.html#new-tab-from-targetblank-click"
|
||||||
|
target="_blank">
|
||||||
|
Open a target page in a new tab from click to link with target="_blank"
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<iframe src="webNav_createdTargetSource_subframe.html" style="width: 100%; height: 100%;">
|
<iframe src="webNav_createdTargetSource_subframe.html" style="width: 100%; height: 100%;">
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@
|
||||||
Open a target page in a new window from mouse click (subframe)
|
Open a target page in a new window from mouse click (subframe)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a id="test-create-new-tab-from-targetblank-click-subframe"
|
||||||
|
href="webNav_createdTarget.html#new-tab-from-targetblank-click-subframe"
|
||||||
|
target="_blank">
|
||||||
|
Open a target page in a new tab from click to link with target="_blank"
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1212,7 +1212,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
||||||
|
|
||||||
// If this tab or window has been opened by a window.open call, we have to provide
|
// If this tab or window has been opened by a window.open call, we have to provide
|
||||||
// all the data needed to send a webNavigation.onCreatedNavigationTarget event.
|
// all the data needed to send a webNavigation.onCreatedNavigationTarget event.
|
||||||
if (aCalledFromJS && parentDocShell && newDocShellItem) {
|
if (parentDocShell && newDocShellItem) {
|
||||||
nsCOMPtr<nsIObserverService> obsSvc =
|
nsCOMPtr<nsIObserverService> obsSvc =
|
||||||
mozilla::services::GetObserverService();
|
mozilla::services::GetObserverService();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue