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:
Luca Greco 2017-03-06 20:55:02 +01:00
Родитель ba91b33caf
Коммит 1387211a0c
4 изменённых файлов: 50 добавлений и 1 удалений

Просмотреть файл

@ -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 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 extension.unload();

Просмотреть файл

@ -30,6 +30,13 @@
Open a target page in a new window from mouse click
</a>
</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>
<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)
</a>
</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>
</body>
</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
// all the data needed to send a webNavigation.onCreatedNavigationTarget event.
if (aCalledFromJS && parentDocShell && newDocShellItem) {
if (parentDocShell && newDocShellItem) {
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();