зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1044351 - prevent popup blocker from blocking windows opened by loaded javascript: URIs by allowing popups for such loads from the location bar. r=mak/mrbkap
--HG-- extra : commitid : Dyy7s6uZnQ6 extra : rebase_source : 0522e3930ce6d9478d7eb55e5266a81fa3ca8451
This commit is contained in:
Родитель
11b4575562
Коммит
43ba25bb7a
|
@ -351,7 +351,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|||
allowThirdPartyFixup: true,
|
||||
disallowInheritPrincipal: !mayInheritPrincipal,
|
||||
allowPinnedTabHostChange: true,
|
||||
postData: postData
|
||||
postData: postData,
|
||||
allowPopups: url.startsWith("javascript:"),
|
||||
});
|
||||
// Ensure the start of the URL is visible for UX reasons:
|
||||
this.selectionStart = this.selectionEnd = 0;
|
||||
|
|
|
@ -188,6 +188,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
|
|||
* relatedToCurrent (boolean)
|
||||
* skipTabAnimation (boolean)
|
||||
* allowPinnedTabHostChange (boolean)
|
||||
* allowPopups (boolean)
|
||||
*/
|
||||
function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI) {
|
||||
var params;
|
||||
|
@ -230,6 +231,7 @@ function openLinkIn(url, where, params) {
|
|||
var aSkipTabAnimation = params.skipTabAnimation;
|
||||
var aAllowPinnedTabHostChange = !!params.allowPinnedTabHostChange;
|
||||
var aNoReferrer = params.noReferrer;
|
||||
var aAllowPopups = !!params.allowPopups;
|
||||
|
||||
if (where == "save") {
|
||||
if (!aInitiatingDoc) {
|
||||
|
@ -342,8 +344,13 @@ function openLinkIn(url, where, params) {
|
|||
// i.e. it causes them not to load at all. Callers should strip
|
||||
// "javascript:" from pasted strings to protect users from malicious URIs
|
||||
// (see stripUnsafeProtocolOnPaste).
|
||||
if (aDisallowInheritPrincipal && !(uriObj && uriObj.schemeIs("javascript")))
|
||||
if (aDisallowInheritPrincipal && !(uriObj && uriObj.schemeIs("javascript"))) {
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
|
||||
}
|
||||
|
||||
if (aAllowPopups) {
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_POPUPS;
|
||||
}
|
||||
|
||||
w.gBrowser.loadURIWithFlags(url, {
|
||||
flags: flags,
|
||||
|
|
|
@ -868,6 +868,7 @@ this.PlacesUIUtils = {
|
|||
}
|
||||
|
||||
aWindow.openUILinkIn(aNode.uri, aWhere, {
|
||||
allowPopups: aNode.uri.startsWith("javascript:"),
|
||||
inBackground: Services.prefs.getBoolPref("browser.tabs.loadBookmarksInBackground"),
|
||||
private: aPrivate,
|
||||
});
|
||||
|
|
|
@ -21,6 +21,9 @@ support-files =
|
|||
[browser_475045.js]
|
||||
[browser_555547.js]
|
||||
[browser_bookmarkProperties_addKeywordForThisSearch.js]
|
||||
[browser_bookmarklet_windowOpen.js]
|
||||
support-files =
|
||||
pageopeningwindow.html
|
||||
[browser_bookmarksProperties.js]
|
||||
[browser_drag_bookmarks_on_toolbar.js]
|
||||
skip-if = e10s # Bug ?????? - test fails - "Number of dragged items should be the same. - Got 0, expected 1"
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
"use strict";
|
||||
|
||||
const TEST_URL = 'http://example.com/browser/browser/components/places/tests/browser/pageopeningwindow.html';
|
||||
|
||||
function makeBookmarkFor(url, keyword) {
|
||||
return Promise.all([
|
||||
PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
title: "bookmarklet",
|
||||
url: url }),
|
||||
PlacesUtils.keywords.insert({url: url,
|
||||
keyword: keyword})
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
add_task(function openKeywordBookmarkWithWindowOpen() {
|
||||
// This is the current default, but let's not assume that...
|
||||
yield new Promise((resolve, reject) => {
|
||||
SpecialPowers.pushPrefEnv({ 'set': [[ 'browser.link.open_newwindow', 3 ],
|
||||
[ 'dom.disable_open_during_load', true ]] },
|
||||
resolve);
|
||||
});
|
||||
|
||||
let moztab;
|
||||
let tabOpened = BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla")
|
||||
.then((tab) => { moztab = tab; });
|
||||
let keywordForBM = "openmeatab";
|
||||
|
||||
let bookmarkInfo;
|
||||
let bookmarkCreated =
|
||||
makeBookmarkFor("javascript:void open('" + TEST_URL + "')", keywordForBM)
|
||||
.then((values) => {
|
||||
bookmarkInfo = values[0];
|
||||
});
|
||||
yield Promise.all([tabOpened, bookmarkCreated]);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
PlacesUtils.bookmarks.remove(bookmarkInfo);
|
||||
PlacesUtils.keywords.remove(keywordForBM);
|
||||
});
|
||||
gURLBar.value = keywordForBM;
|
||||
gURLBar.focus();
|
||||
|
||||
let tabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
|
||||
info("Waiting for tab being created");
|
||||
let {target: tab} = yield tabCreatedPromise;
|
||||
info("Got tab");
|
||||
let browser = tab.linkedBrowser;
|
||||
if (!browser.currentURI || browser.currentURI.spec != TEST_URL) {
|
||||
info("Waiting for browser load");
|
||||
yield BrowserTestUtils.browserLoaded(browser);
|
||||
}
|
||||
is(browser.currentURI && browser.currentURI.spec, TEST_URL, "Tab with expected URL loaded.");
|
||||
info("Waiting to remove tab");
|
||||
yield Promise.all([ BrowserTestUtils.removeTab(tab),
|
||||
BrowserTestUtils.removeTab(moztab) ]);
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
Hi, I was opened via a <script>document.write(location.search ?
|
||||
"popup call from the opened window... uh oh, that shouldn't happen!" :
|
||||
"bookmarklet, and I will open a new window myself.")</script><br>
|
||||
<script>
|
||||
if (!location.search) {
|
||||
open(location.href + "?donotopen=true", '_blank');
|
||||
}
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче