зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1339440
use frameUrl to match context menus on frames r=kmag
MozReview-Commit-ID: LIlAZIP4HNx --HG-- extra : rebase_source : 2272774352a8d1cfaf9a6b209891c9bfd94fff19
This commit is contained in:
Родитель
e4de847b3c
Коммит
eefe88f8e9
|
@ -517,7 +517,7 @@ MenuItem.prototype = {
|
|||
}
|
||||
|
||||
let docPattern = this.documentUrlMatchPattern;
|
||||
let pageURI = Services.io.newURI(contextData.pageUrl);
|
||||
let pageURI = Services.io.newURI(contextData[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");
|
||||
|
|
Загрузка…
Ссылка в новой задаче