mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1260102 - Pass isHandlingUserInput through process boundary for content menu command. r=mrbkap, a=ritu
MozReview-Commit-ID: FMQOFpeO6yn
This commit is contained in:
parent
f661ffab3b
commit
08fdabbbc1
@ -16,6 +16,8 @@ Cu.import("resource://gre/modules/InlineSpellChecker.jsm");
|
||||
Cu.import("resource://gre/modules/InlineSpellCheckerContent.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
|
||||
"resource:///modules/E10SUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ContentLinkHandler",
|
||||
@ -49,7 +51,9 @@ var global = this;
|
||||
var formSubmitObserver = new FormSubmitObserver(content, this);
|
||||
|
||||
addMessageListener("ContextMenu:DoCustomCommand", function(message) {
|
||||
PageMenuChild.executeMenu(message.data);
|
||||
E10SUtils.wrapHandlingUserInput(
|
||||
content, message.data.handlingUserInput,
|
||||
() => PageMenuChild.executeMenu(message.data.generatedItemId));
|
||||
});
|
||||
|
||||
addMessageListener("RemoteLogins:fillForm", function(message) {
|
||||
|
@ -68,15 +68,10 @@ addMessageListener("Browser:Reload", function(message) {
|
||||
}
|
||||
|
||||
let reloadFlags = message.data.flags;
|
||||
let handlingUserInput;
|
||||
try {
|
||||
handlingUserInput = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.setHandlingUserInput(message.data.handlingUserInput);
|
||||
webNav.reload(reloadFlags);
|
||||
E10SUtils.wrapHandlingUserInput(content, message.data.handlingUserInput,
|
||||
() => webNav.reload(reloadFlags));
|
||||
} catch (e) {
|
||||
} finally {
|
||||
handlingUserInput.destruct();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -102,4 +102,16 @@ this.E10SUtils = {
|
||||
});
|
||||
return false;
|
||||
},
|
||||
|
||||
wrapHandlingUserInput: function(aWindow, aIsHandling, aCallback) {
|
||||
var handlingUserInput;
|
||||
try {
|
||||
handlingUserInput = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.setHandlingUserInput(aIsHandling);
|
||||
aCallback();
|
||||
} finally {
|
||||
handlingUserInput.destruct();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -5,6 +5,7 @@ support-files =
|
||||
file_bug649778.html
|
||||
file_bug649778.html^headers^
|
||||
file_fullscreen-api-keys.html
|
||||
file_content_contextmenu.html
|
||||
head.js
|
||||
|
||||
[browser_bug592641.js]
|
||||
@ -19,3 +20,5 @@ support-files =
|
||||
[browser_DOMDocElementInserted.js]
|
||||
[browser_fullscreen-api-keys.js]
|
||||
[browser_fullscreen-contextmenu-esc.js]
|
||||
tags = fullscreen
|
||||
[browser_content_contextmenu_userinput.js]
|
||||
|
61
dom/html/test/browser_content_contextmenu_userinput.js
Normal file
61
dom/html/test/browser_content_contextmenu_userinput.js
Normal file
@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
|
||||
function frameScript() {
|
||||
let Ci = Components.interfaces;
|
||||
let windowUtils = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
let menuitem = content.document.getElementById("menuitem");
|
||||
menuitem.addEventListener("click", function() {
|
||||
sendAsyncMessage("Test:ContextMenuClick", windowUtils.isHandlingUserInput);
|
||||
});
|
||||
}
|
||||
|
||||
var gMessageManager;
|
||||
|
||||
function listenOneMessage(aMsg, aListener) {
|
||||
function listener({ data }) {
|
||||
gMessageManager.removeMessageListener(aMsg, listener);
|
||||
aListener(data);
|
||||
}
|
||||
gMessageManager.addMessageListener(aMsg, listener);
|
||||
}
|
||||
|
||||
function promiseOneMessage(aMsg) {
|
||||
return new Promise(resolve => listenOneMessage(aMsg, resolve));
|
||||
}
|
||||
|
||||
const kPage = "http://example.org/browser/" +
|
||||
"dom/html/test/file_content_contextmenu.html";
|
||||
|
||||
add_task(function* () {
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: kPage
|
||||
}, function*(aBrowser) {
|
||||
gMessageManager = aBrowser.messageManager;
|
||||
ContentTask.spawn(aBrowser, null, frameScript);
|
||||
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu");
|
||||
|
||||
info("Open context menu");
|
||||
is(contextMenu.state, "closed", "Should not have opened context menu");
|
||||
let popupShownPromise = promiseWaitForEvent(window, "popupshown");
|
||||
EventUtils.synthesizeMouse(aBrowser, window.innerWidth / 3,
|
||||
window.innerHeight / 3,
|
||||
{type: "contextmenu", button: 2}, window);
|
||||
yield popupShownPromise;
|
||||
is(contextMenu.state, "open", "Should have opened context menu");
|
||||
|
||||
let pageMenuSep = document.getElementById("page-menu-separator");
|
||||
ok(pageMenuSep && !pageMenuSep.hidden,
|
||||
"Page menu separator should be shown");
|
||||
let testMenuItem = pageMenuSep.previousSibling;
|
||||
is(testMenuItem.label, "Test Context Menu Click", "Got context menu item");
|
||||
|
||||
let promiseContextMenuClick = promiseOneMessage("Test:ContextMenuClick");
|
||||
EventUtils.synthesizeMouseAtCenter(testMenuItem, {}, window);
|
||||
let isUserInput = yield promiseContextMenuClick;
|
||||
ok(isUserInput, "Content menu click should be a user input");
|
||||
});
|
||||
});
|
19
dom/html/test/file_content_contextmenu.html
Normal file
19
dom/html/test/file_content_contextmenu.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body contextmenu="testmenu">
|
||||
<menu type="context" id="testmenu">
|
||||
<menuitem label="Test Context Menu Click" id="menuitem">
|
||||
</menu>
|
||||
</body>
|
||||
</html>
|
@ -4,6 +4,8 @@
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["PageMenuParent", "PageMenuChild"];
|
||||
|
||||
var {interfaces: Ci} = Components;
|
||||
|
||||
this.PageMenu = function PageMenu() {
|
||||
}
|
||||
|
||||
@ -162,8 +164,13 @@ PageMenu.prototype = {
|
||||
this._builder.click(target.getAttribute(this.GENERATEDITEMID_ATTR));
|
||||
}
|
||||
else if (this._browser) {
|
||||
this._browser.messageManager.sendAsyncMessage("ContextMenu:DoCustomCommand",
|
||||
target.getAttribute(this.GENERATEDITEMID_ATTR));
|
||||
let win = target.ownerDocument.defaultView;
|
||||
let windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
this._browser.messageManager.sendAsyncMessage("ContextMenu:DoCustomCommand", {
|
||||
generatedItemId: target.getAttribute(this.GENERATEDITEMID_ATTR),
|
||||
handlingUserInput: windowUtils.isHandlingUserInput
|
||||
});
|
||||
}
|
||||
} else if (type == "popuphidden" && this._popup == target) {
|
||||
this.removeGeneratedContent(this._popup);
|
||||
|
Loading…
Reference in New Issue
Block a user