Bug 1339440 use frameUrl to match context menus on frames r=kmag

MozReview-Commit-ID: LIlAZIP4HNx

--HG--
extra : rebase_source : 2c66049fa29bbd7e64eae485a26f764ef0041903
This commit is contained in:
Shane Caraveo 2017-03-15 15:58:53 -07:00
Родитель a4dc8a2777
Коммит caabad8144
6 изменённых файлов: 37 добавлений и 3 удалений

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

@ -517,7 +517,7 @@ MenuItem.prototype = {
}
let docPattern = this.documentUrlMatchPattern;
let pageURI = Services.io.newURI(contextData.pageUrl);
let pageURI = Services.io.newURI(contextData["inFrame" ? "frameUrl" : "pageUrl"]);
if (docPattern && !docPattern.matches(pageURI)) {
return false;
}

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

@ -4,6 +4,7 @@ support-files =
head_pageAction.js
head_sessions.js
context.html
context_frame.html
ctxmenu-image.png
context_tabs_onUpdated_page.html
context_tabs_onUpdated_iframe.html

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

@ -52,10 +52,16 @@ add_task(function* () {
// Test menu items using documentUrlPatterns.
browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextAll",
documentUrlPatterns: ["*://*/*context.html"],
documentUrlPatterns: ["*://*/*context*.html"],
contexts: ["all"],
});
browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextFrame",
documentUrlPatterns: ["*://*/*context_frame.html"],
contexts: ["frame"],
});
browser.contextMenus.create({
title: "documentUrlPatterns-patternMatches-contextImage",
documentUrlPatterns: ["*://*/*context.html", "http://*/url-that-does-not-match"],
@ -249,6 +255,14 @@ add_task(function* () {
yield confirmContextMenuItems(contextMenu, expected);
yield closeContextMenu();
contextMenu = yield openContextMenuInFrame("frame");
expected = [
["documentUrlPatterns-patternMatches-contextAll", true],
["documentUrlPatterns-patternMatches-contextFrame", true],
];
yield confirmContextMenuItems(contextMenu, expected);
yield closeContextMenu();
yield extension.unload();
yield BrowserTestUtils.removeTab(tab1);
});

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

@ -20,5 +20,6 @@
<input type="text" id="edit-me"><br>
<input type="password" id="password">
</p>
<iframe id="frame" src="context_frame.html"/>
</body>
</html>

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

@ -0,0 +1,8 @@
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Just some text
</body>
</html>

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

@ -16,7 +16,7 @@
* getListStyleImage getPanelForNode
* awaitExtensionPanel awaitPopupResize
* promiseContentDimensions alterContent
* promisePrefChangeObserved
* promisePrefChangeObserved openContextMenuInFrame
*/
const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm", {});
@ -232,6 +232,16 @@ function closeBrowserAction(extension, win = window) {
return Promise.resolve();
}
async function openContextMenuInFrame(frameId) {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
let doc = gBrowser.selectedBrowser.contentDocument;
let frame = doc.getElementById(frameId);
EventUtils.synthesizeMouseAtCenter(frame.contentDocument.body, {type: "contextmenu"}, frame.contentWindow);
await popupShownPromise;
return contentAreaContextMenu;
}
async function openContextMenu(selector = "#img1") {
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");