Backed out changeset fa6795d107b1 (bug 1745005) for causing multiple failures. CLOSED TREE

This commit is contained in:
criss
2022-04-13 13:23:03 +03:00
parent acbdc52c4a
commit a2a5bc115b
11 changed files with 212 additions and 127 deletions

View File

@@ -24,7 +24,6 @@
#include "mozilla/dom/UserActivation.h"
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/dom/WheelEventBinding.h"
#include "mozilla/dom/WindowGlobalChild.h"
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/TextUtils.h"
@@ -5523,74 +5522,6 @@ void HTMLInputElement::SetSelectionDirection(const nsAString& aDirection,
state->SetSelectionDirection(aDirection, aRv);
}
// https://html.spec.whatwg.org/multipage/input.html#dom-input-showpicker
void HTMLInputElement::ShowPicker(ErrorResult& aRv) {
// Step 1. If this is not mutable, then throw an "InvalidStateError"
// DOMException.
if (!IsMutable()) {
return aRv.ThrowInvalidStateError(
"This input is either disabled or readonly.");
}
// Step 2. If this's relevant settings object's origin is not same origin with
// this's relevant settings object's top-level origin, and this's type
// attribute is not in the File Upload state or Color state, then throw a
// "SecurityError" DOMException.
if (mType != FormControlType::InputFile &&
mType != FormControlType::InputColor) {
nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
WindowGlobalChild* windowGlobalChild =
window ? window->GetWindowGlobalChild() : nullptr;
if (!windowGlobalChild || !windowGlobalChild->SameOriginWithTop()) {
return aRv.ThrowSecurityError(
"Call was blocked because the current origin isn't same-origin with "
"top.");
}
}
// Step 3. If this's relevant global object does not have transient
// activation, then throw a "NotAllowedError" DOMException.
if (!OwnerDoc()->HasValidTransientUserGestureActivation()) {
return aRv.ThrowNotAllowedError(
"Call was blocked due to lack of user activation.");
}
// Step 4. Show the picker, if applicable, for this.
//
// https://html.spec.whatwg.org/multipage/input.html#show-the-picker,-if-applicable
// To show the picker, if applicable for an input element element:
// Step 1. Assert: element's relevant global object has transient activation.
// Step 2. If element is not mutable, then return.
// (See above.)
// Step 3. If element's type attribute is in the File Upload state, then run
// these steps in parallel:
if (mType == FormControlType::InputFile) {
FilePickerType type = FILE_PICKER_FILE;
if (StaticPrefs::dom_webkitBlink_dirPicker_enabled() &&
HasAttr(nsGkAtoms::webkitdirectory)) {
type = FILE_PICKER_DIRECTORY;
}
InitFilePicker(type);
return;
}
// Step 4. Otherwise, the user agent should show any relevant user interface
// for selecting a value for element, in the way it normally would when the
// user interacts with the control
if (mType == FormControlType::InputColor) {
InitColorPicker();
return;
}
if (IsDateTimeInputType(mType) && IsInComposedDoc()) {
DateTimeValue value;
GetDateTimeInputBoxValue(value);
OpenDateTimePicker(value);
}
}
#ifdef ACCESSIBILITY
/*static*/ nsresult FireEventForAccessibility(HTMLInputElement* aTarget,
EventMessage aEventMessage) {

View File

@@ -699,8 +699,6 @@ class HTMLInputElement final : public TextControlElement,
SelectionMode aSelectMode,
ErrorResult& aRv);
void ShowPicker(ErrorResult& aRv);
bool WebkitDirectoryAttr() const {
return HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory);
}

View File

@@ -27,7 +27,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=885996
{ id: 'normal', type: 'prevent-default-1', result: false },
{ id: 'normal', type: 'prevent-default-2', result: false },
{ id: 'normal', type: 'click-method', result: true },
{ id: 'normal', type: 'show-picker', result: true },
{ id: 'normal', type: 'right-click', result: false },
{ id: 'normal', type: 'middle-click', result: false },
{ id: 'label-1', result: true },
@@ -88,10 +87,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=885996
case 'click-method':
element.click();
break;
case 'show-picker':
SpecialPowers.wrap(document).notifyUserGestureActivation();
element.showPicker();
break;
case 'right-click':
synthesizeMouseAtCenter(element, { button: 2 });
break;

View File

@@ -62,7 +62,6 @@
<div id='div-click-on-demand' onclick="var i=document.createElement('input'); i.type='file'; i.click();" tabindex='1'>foo</div>
<div id='div-keydown' onkeydown="document.getElementById('by-button').click();" tabindex='1'>foo</div>
<a id='link-click' href="javascript:document.getElementById('by-button').click();" tabindex='1'>foo</a>
<input id='show-picker' type='file'>
</div>
<pre id="test">
<script type="application/javascript">
@@ -136,7 +135,6 @@ var testData = [["a", 1, MockFilePicker.filterImages, 1],
["div-click-on-demand", 0, undefined, 0],
["div-keydown", 0, undefined, 0],
["link-click", 0, undefined, 0],
["show-picker", 0, undefined, 0],
];
var currentTest = 0;
@@ -204,9 +202,6 @@ function launchNextTest() {
synthesizeMouseAtCenter(document.getElementById(testData[currentTest][0]), {});
} else if (testData[currentTest][0] == 'div-keydown') {
sendString("a");
} else if (testData[currentTest][0] == 'show-picker') {
SpecialPowers.wrap(document).notifyUserGestureActivation();
document.getElementById(testData[currentTest][0]).showPicker();
} else {
document.getElementById(testData[currentTest][0]).click();
}

View File

@@ -134,9 +134,6 @@ interface HTMLInputElement : HTMLElement {
[Throws]
void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
[Throws, Pref="dom.input.showPicker"]
void showPicker();
// also has obsolete members
};

View File

@@ -2652,12 +2652,6 @@
value: true
mirror: always
# Is support for HTMLInputElement.showPicker enabled?
- name: dom.input.showPicker
type: bool
value: true
mirror: always
# Whether to allow or disallow web apps to cancel `beforeinput` events caused
# by MozEditableElement#setUserInput() which is used by autocomplete, autofill
# and password manager.

View File

@@ -752,6 +752,78 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[HTMLMetaElement interface: document.createElement("meta") must inherit property "media" with the proper type]
expected: FAIL
[HTMLInputElement interface: operation showPicker()]
expected: FAIL
[HTMLInputElement interface: document.createElement("input") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("text") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("hidden") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("search") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("tel") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("url") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("email") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("password") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("date") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("month") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("week") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("time") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("datetime-local") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("number") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("range") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("color") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("checkbox") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("radio") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("file") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("submit") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("image") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("reset") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLInputElement interface: createInput("button") must inherit property "showPicker()" with the proper type]
expected: FAIL
[HTMLElement interface: attribute inert]
expected: FAIL

View File

@@ -0,0 +1,6 @@
[show-picker-cross-origin-iframe.html]
[Test showPicker() called from cross-origin iframe 1]
expected: FAIL
[Test showPicker() called from cross-origin iframe 3]
expected: FAIL

View File

@@ -0,0 +1,132 @@
[show-picker.html]
[input[type=button\] showPicker() requires a user gesture]
expected: FAIL
[input[type=checkbox\] showPicker() requires a user gesture]
expected: FAIL
[input[type=color\] showPicker() requires a user gesture]
expected: FAIL
[input[type=date\] showPicker() requires a user gesture]
expected: FAIL
[input[type=datetime-local\] showPicker() requires a user gesture]
expected: FAIL
[input[type=email\] showPicker() requires a user gesture]
expected: FAIL
[input[type=file\] showPicker() requires a user gesture]
expected: FAIL
[input[type=hidden\] showPicker() requires a user gesture]
expected: FAIL
[input[type=image\] showPicker() requires a user gesture]
expected: FAIL
[input[type=month\] showPicker() requires a user gesture]
expected: FAIL
[input[type=number\] showPicker() requires a user gesture]
expected: FAIL
[input[type=password\] showPicker() requires a user gesture]
expected: FAIL
[input[type=radio\] showPicker() requires a user gesture]
expected: FAIL
[input[type=range\] showPicker() requires a user gesture]
expected: FAIL
[input[type=reset\] showPicker() requires a user gesture]
expected: FAIL
[input[type=search\] showPicker() requires a user gesture]
expected: FAIL
[input[type=submit\] showPicker() requires a user gesture]
expected: FAIL
[input[type=tel\] showPicker() requires a user gesture]
expected: FAIL
[input[type=text\] showPicker() requires a user gesture]
expected: FAIL
[input[type=time\] showPicker() requires a user gesture]
expected: FAIL
[input[type=url\] showPicker() requires a user gesture]
expected: FAIL
[input[type=week\] showPicker() requires a user gesture]
expected: FAIL
[input[type=button\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=checkbox\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=color\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=date\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=datetime-local\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=email\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=file\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=hidden\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=image\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=month\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=number\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=password\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=radio\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=range\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=reset\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=search\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=submit\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=tel\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=text\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=time\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=url\] showPicker() does not throw when user activation is active]
expected: FAIL
[input[type=week\] showPicker() does not throw when user activation is active]
expected: FAIL

View File

@@ -987,30 +987,3 @@ add_task(async function test_datepicker_value_higher_than_max() {
await helper.tearDown();
});
/**
* Test that date picker opens with showPicker.
*/
add_task(async function test_datepicker_showPicker() {
const date = new Date();
await helper.openPicker(
"data:text/html, <input type='date'>",
false,
"showPicker"
);
if (date.getMonth() === new Date().getMonth()) {
Assert.equal(
helper.getElement(MONTH_YEAR).textContent,
DATE_FORMAT_LOCAL(date)
);
} else {
Assert.ok(
true,
"Skipping datepicker today test if month changes when opening picker."
);
}
await helper.tearDown();
});

View File

@@ -186,9 +186,8 @@ class DateTimeTestHelper {
*
* @param {String} pageUrl
* @param {bool} inFrame true if input is in the first child frame
* @param {String} openMethod "click" or "showPicker"
*/
async openPicker(pageUrl, inFrame, openMethod = "click") {
async openPicker(pageUrl, inFrame) {
this.tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
let bc = gBrowser.selectedBrowser;
if (inFrame) {
@@ -200,14 +199,7 @@ class DateTimeTestHelper {
});
bc = bc.browsingContext.children[0];
}
if (openMethod === "click") {
await BrowserTestUtils.synthesizeMouseAtCenter("input", {}, bc);
} else if (openMethod === "showPicker") {
await SpecialPowers.spawn(bc, [], function() {
content.document.notifyUserGestureActivation();
content.document.querySelector("input").showPicker();
});
}
await BrowserTestUtils.synthesizeMouseAtCenter("input", {}, bc);
this.frame = this.panel.querySelector("#dateTimePopupFrame");
await this.waitForPickerReady();
}