mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
moebius#72: Fix Marionette's DateTimeValue when dom.forms.datetime is enabled
This commit is contained in:
parent
9c7b814103
commit
1a36c4a8ac
2 changed files with 54 additions and 0 deletions
|
|
@ -76,6 +76,30 @@ const SELECTED_PROPERTY_SUPPORTED_XUL = new Set([
|
|||
"TAB",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Common form controls that user can change the value property interactively.
|
||||
*/
|
||||
const COMMON_FORM_CONTROLS = new Set([
|
||||
"input",
|
||||
"textarea",
|
||||
"select",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Input elements that do not fire "input" and "change" events when value
|
||||
* property changes.
|
||||
*/
|
||||
const INPUT_TYPES_NO_EVENT = new Set([
|
||||
"checkbox",
|
||||
"radio",
|
||||
"file",
|
||||
"hidden",
|
||||
"image",
|
||||
"reset",
|
||||
"button",
|
||||
"submit",
|
||||
]);
|
||||
|
||||
this.interaction = {};
|
||||
|
||||
/**
|
||||
|
|
@ -338,6 +362,32 @@ interaction.uploadFile = function (el, path) {
|
|||
event.change(el);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets a form element's value.
|
||||
*
|
||||
* @param {DOMElement} el
|
||||
* An form element, e.g. input, textarea, etc.
|
||||
* @param {string} value
|
||||
* The value to be set.
|
||||
*
|
||||
* @throws TypeError
|
||||
* If |el| is not an supported form element.
|
||||
*/
|
||||
interaction.setFormControlValue = function* (el, value) {
|
||||
if (!COMMON_FORM_CONTROLS.has(el.localName)) {
|
||||
throw new TypeError("This function is for form elements only");
|
||||
}
|
||||
|
||||
el.value = value;
|
||||
|
||||
if (INPUT_TYPES_NO_EVENT.has(el.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.input(el);
|
||||
event.change(el);
|
||||
};
|
||||
|
||||
/**
|
||||
* Send keys to element.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ Cu.import("chrome://marionette/content/session.js");
|
|||
Cu.import("chrome://marionette/content/simpletest.js");
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
|
@ -1465,6 +1466,9 @@ function* sendKeysToElement(id, val) {
|
|||
if (el.type == "file") {
|
||||
let path = val.join("");
|
||||
yield interaction.uploadFile(el, path);
|
||||
} else if ((el.type == "date" || el.type == "time") &&
|
||||
Preferences.get("dom.forms.datetime")) {
|
||||
yield interaction.setFormControlValue(el, val);
|
||||
} else {
|
||||
yield interaction.sendKeysToElement(
|
||||
el, val, false, capabilities.get("moz:accessibilityChecks"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue