mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1131573 - Add contextmenu support to input elements in forms. r=kanru
This commit is contained in:
parent
2069e0c923
commit
9f1c6593b0
@ -808,10 +808,10 @@ BrowserElementChild.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The value returned by the contextmenu sync call is true iff the embedder
|
// The value returned by the contextmenu sync call is true if the embedder
|
||||||
// called preventDefault() on its contextmenu event.
|
// called preventDefault() on its contextmenu event.
|
||||||
//
|
//
|
||||||
// We call preventDefault() on our contextmenu event iff the embedder called
|
// We call preventDefault() on our contextmenu event if the embedder called
|
||||||
// preventDefault() on /its/ contextmenu event. This way, if the embedder
|
// preventDefault() on /its/ contextmenu event. This way, if the embedder
|
||||||
// ignored the contextmenu event, TabChild will fire a click.
|
// ignored the contextmenu event, TabChild will fire a click.
|
||||||
if (sendSyncMsg('contextmenu', menuData)[0]) {
|
if (sendSyncMsg('contextmenu', menuData)[0]) {
|
||||||
@ -838,6 +838,29 @@ BrowserElementChild.prototype = {
|
|||||||
(elem.videoWidth == 0 || elem.videoHeight == 0));
|
(elem.videoWidth == 0 || elem.videoHeight == 0));
|
||||||
return {uri: elem.currentSrc || elem.src, hasVideo: hasVideo};
|
return {uri: elem.currentSrc || elem.src, hasVideo: hasVideo};
|
||||||
}
|
}
|
||||||
|
if (elem instanceof Ci.nsIDOMHTMLInputElement &&
|
||||||
|
elem.hasAttribute("name")) {
|
||||||
|
// For input elements, we look for a parent <form> and if there is
|
||||||
|
// one we return the form's method and action uri.
|
||||||
|
let parent = elem.parentNode;
|
||||||
|
while (parent) {
|
||||||
|
if (parent instanceof Ci.nsIDOMHTMLFormElement &&
|
||||||
|
parent.hasAttribute("action")) {
|
||||||
|
let actionHref = docShell.QueryInterface(Ci.nsIWebNavigation)
|
||||||
|
.currentURI
|
||||||
|
.resolve(parent.getAttribute("action"));
|
||||||
|
let method = parent.hasAttribute("method")
|
||||||
|
? parent.getAttribute("method").toLowerCase()
|
||||||
|
: "get";
|
||||||
|
return {
|
||||||
|
action: actionHref,
|
||||||
|
method: method,
|
||||||
|
name: elem.getAttribute("name"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parent = parent.parentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -165,11 +165,47 @@ function checkAudioinVideoContextMenu() {
|
|||||||
is(target.data.uri, audioUrl, 'Reports uri correctly in data');
|
is(target.data.uri, audioUrl, 'Reports uri correctly in data');
|
||||||
is(target.data.hasVideo, false, 'Audio data in video tag reports no "hasVideo"');
|
is(target.data.hasVideo, false, 'Audio data in video tag reports no "hasVideo"');
|
||||||
|
|
||||||
SimpleTest.finish();
|
checkFormNoMethod();
|
||||||
}, /* ignorePreventDefault */ true);
|
}, /* ignorePreventDefault */ true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkFormNoMethod() {
|
||||||
|
sendContextMenuTo('#menu7-trigger', function onContextMenu(detail) {
|
||||||
|
var target = detail.systemTargets[0];
|
||||||
|
is(target.nodeName, 'INPUT', 'Reports correct nodeName');
|
||||||
|
is(target.data.method, 'get', 'Reports correct method');
|
||||||
|
is(target.data.action, 'no_method', 'Reports correct action url');
|
||||||
|
is(target.data.name, 'input1', 'Reports correct input name');
|
||||||
|
|
||||||
|
checkFormGetMethod();
|
||||||
|
}, /* ignorePreventDefault */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFormGetMethod() {
|
||||||
|
sendContextMenuTo('#menu8-trigger', function onContextMenu(detail) {
|
||||||
|
var target = detail.systemTargets[0];
|
||||||
|
is(target.nodeName, 'INPUT', 'Reports correct nodeName');
|
||||||
|
is(target.data.method, 'get', 'Reports correct method');
|
||||||
|
is(target.data.action, 'http://example.com/get_method', 'Reports correct action url');
|
||||||
|
is(target.data.name, 'input2', 'Reports correct input name');
|
||||||
|
|
||||||
|
checkFormPostMethod();
|
||||||
|
}, /* ignorePreventDefault */ true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkFormPostMethod() {
|
||||||
|
sendContextMenuTo('#menu9-trigger', function onContextMenu(detail) {
|
||||||
|
var target = detail.systemTargets[0];
|
||||||
|
is(target.nodeName, 'INPUT', 'Reports correct nodeName');
|
||||||
|
is(target.data.method, 'post', 'Reports correct method');
|
||||||
|
is(target.data.action, 'post_method', 'Reports correct action url');
|
||||||
|
is(target.data.name, 'input3', 'Reports correct input name');
|
||||||
|
|
||||||
|
SimpleTest.finish();
|
||||||
|
}, /* ignorePreventDefault */ true);
|
||||||
|
}
|
||||||
|
|
||||||
/* Helpers */
|
/* Helpers */
|
||||||
var mm = null;
|
var mm = null;
|
||||||
var previousContextMenuDetail = null;
|
var previousContextMenuDetail = null;
|
||||||
@ -240,6 +276,9 @@ function createIframe(callback) {
|
|||||||
'<video id="menu4-trigger" src="' + videoUrl + '"></video>' +
|
'<video id="menu4-trigger" src="' + videoUrl + '"></video>' +
|
||||||
'<video id="menu5-trigger" preload="metadata"></video>' +
|
'<video id="menu5-trigger" preload="metadata"></video>' +
|
||||||
'<audio id="menu6-trigger" src="' + audioUrl + '"></audio>' +
|
'<audio id="menu6-trigger" src="' + audioUrl + '"></audio>' +
|
||||||
|
'<form action="no_method"><input id="menu7-trigger" name="input1"></input></form>' +
|
||||||
|
'<form action="http://example.com/get_method" method="get"><input id="menu8-trigger" name="input2"></input></form>' +
|
||||||
|
'<form action="post_method" method="post"><input id="menu9-trigger" name="input3"></input></form>' +
|
||||||
'</body></html>';
|
'</body></html>';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user