Skip to content

Commit

Permalink
Re-import html/semantics/forms/the-select-elements WPT
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=262783

Reviewed by Tim Nguyen.

WPT Commit: 3538a9f3031846a83f95f9c514388fc4f35437fc

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/resources/import-expectations.json:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/inserted-or-removed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/inserted-or-removed.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/resources/show-picker-child-iframe.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/resources/w3c-import.log: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-add-optgroup-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-add-optgroup.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-cross-origin-iframe.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-disabled.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-multiple.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-size.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-user-gesture.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/w3c-import.log:
* LayoutTests/tests-options.json:

Canonical link: https://commits.webkit.org/268997@main
  • Loading branch information
lukewarlow authored and nt1m committed Oct 6, 2023
1 parent 31afc76 commit d8c00ef
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 1 deletion.
6 changes: 6 additions & 0 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -6193,6 +6193,7 @@ imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/delay-load-event-until-move-to-empty-source.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-move-into-script-disabled-iframe.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-cross-origin-iframe.tentative.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-cross-origin-iframe.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/proxy-modifier-click-to-associated-element.tentative.html [ Skip ]
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/028.html [ Skip ]
Expand Down Expand Up @@ -6740,6 +6741,11 @@ imported/w3c/web-platform-tests/css/css-inline/baseline-source/baseline-source-f
imported/w3c/web-platform-tests/css/css-inline/baseline-source/baseline-source-last-002.html [ Pass Failure ]
imported/w3c/web-platform-tests/css/css-inline/baseline-source/baseline-source-last-003.html [ Pass Failure ]

webkit.org/b/261814 imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-disabled.tentative.html [ Skip ]
webkit.org/b/261814 imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-size.tentative.html [ Skip ]
webkit.org/b/261814 imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-multiple.tentative.html [ Skip ]
webkit.org/b/261814 imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-user-gesture.tentative.html [ Skip ]

webkit.org/b/245032 imported/w3c/web-platform-tests/css/compositing/root-element-background-image-transparency-004.html [ ImageOnlyFailure ]

webkit.org/b/261916 media/video-pause-while-seeking.html [ Pass Failure ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@
"web-platform-tests/html/semantics/forms": "import",
"web-platform-tests/html/semantics/forms/textfieldselection/select-event.html": "skip",
"web-platform-tests/html/semantics/forms/textfieldselection/textfieldselection-setRangeText.html": "skip",
"web-platform-tests/html/semantics/forms/the-textarea-element": "import",
"web-platform-tests/html/semantics/interactive-elements/the-details-element": "import",
"web-platform-tests/html/semantics/interactive-elements/the-dialog-element": "import",
"web-platform-tests/html/semantics/interactive-elements/the-summary-element": "skip",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PASS The last selected OPTION should win; Inserted by parser
PASS The last selected OPTION should win; Inserted by DOM API
PASS The last selected OPTION should win; Inserted by jQuery append()
PASS The last selected OPTION should win; Inserted by innerHTML
PASS If an OPTION says it is selected, it should be selected after it is inserted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,21 @@
'<option selected>Fourth</option>';
assert_equals(target.selectedOptions[0].textContent, 'Fourth');
}, 'The last selected OPTION should win; Inserted by innerHTML');

test (() => {
for (let insert_location = 0; insert_location < 3; ++insert_location) {
const target = document.querySelector('#by-innerHTML');
target.innerHTML = '<option>A</option>' +
'<option selected>C</option>' +
'<option>D</option>';
const refNode = target.querySelectorAll('option')[insert_location];

const opt = document.createElement('option');
opt.selected = true;
opt.textContent = 'B';
target.insertBefore(opt, refNode);
assert_equals(target.selectedOptions[0].textContent, 'B');
}
}, 'If an OPTION says it is selected, it should be selected after it is inserted.');
</script>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>Test showPicker() in an iframe</title>
<script type=module>
const urlParams = new URLSearchParams(location.search);
const documentDomain = urlParams.get('documentDomain');
if (documentDomain) {
document.domain = documentDomain;
}

let securityErrors = [];
const select = document.createElement("select");
try {
select.showPicker();
} catch (error) {
if (error instanceof DOMException && error.name == 'SecurityError') {
securityErrors.push("select");
}
}
parent.postMessage(securityErrors.join(','), "*");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The tests in this directory were imported from the W3C repository.
Do NOT modify these tests directly in WebKit.
Instead, create a pull request on the WPT github:
https://github.com/web-platform-tests/wpt

Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport

Do NOT modify or remove this file.

------------------------------------------------------------------------
Properties requiring vendor prefixes:
None
Property values requiring vendor prefixes:
None
------------------------------------------------------------------------
List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/resources/show-picker-child-iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


FAIL select.add() with an index should work when the target is inside an optgroup. The object can not be found here.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1477785">
<link rel=help href="https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<select>
<option id=opt1>opt1</option>
<optgroup label=group1>
<option id=opt2>opt2</option>
</optgroup>
</select>

<script>
test(() => {
const select = document.querySelector('select');
const optgroup = document.querySelector('optgroup');
const newOption = document.createElement('option');
newOption.textContent = 'new option';

select.options.add(newOption, 1);
assert_equals(select.options.length, 3);
assert_equals(select.options[0], opt1, 'First item should be opt1.');
assert_equals(select.options[1], newOption, 'Second item should be newOption.');
assert_equals(select.options[2], opt2, 'Third item should be opt2.');
assert_equals(newOption.parentNode, optgroup, 'The new option should be inside the optgroup.');
}, 'select.add() with an index should work when the target is inside an optgroup.');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<title>Test showPicker() called from cross-origin iframe</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<body>
<iframe id="iframe1"></iframe>
<iframe id="iframe2"></iframe>
<iframe id="iframe3"></iframe>
<iframe id="iframe4"></iframe>
</body>
<script>
function waitForSecurityErrors() {
return new Promise((resolve) => {
window.addEventListener("message", (event) => resolve(event.data), {
once: true,
});
});
}

promise_test(async (t) => {
iframe1.src =
new URL("resources/", self.location).pathname +
"show-picker-child-iframe.html";

// Wait for the iframe to report security errors when calling showPicker().
const securityErrors = await waitForSecurityErrors();
assert_equals(
securityErrors,
"",
"In same-origin iframes, showPicker() does not throw a SecurityError."
);
});

promise_test(async (t) => {
iframe2.src =
get_host_info().HTTP_NOTSAMESITE_ORIGIN +
new URL("resources/", self.location).pathname +
"show-picker-child-iframe.html";

// Wait for the iframe to report security errors when calling showPicker().
const securityErrors = await waitForSecurityErrors();
assert_equals(
securityErrors,
"select",
"In cross-origin iframes, showPicker() throws a SecurityError."
);
});

promise_test(async (t) => {
iframe3.src =
new URL("resources/", self.location).pathname +
"show-picker-child-iframe.html?documentDomain=" + get_host_info().ORIGINAL_HOST;

// Wait for the iframe to report security errors when calling showPicker().
const securityErrors = await waitForSecurityErrors();
assert_equals(
securityErrors,
"",
"In same-origin but cross-origin-domain iframes, showPicker() does not throw a SecurityError."
);
});

promise_test(async (t) => {
document.domain = get_host_info().ORIGINAL_HOST;
iframe4.src =
get_host_info().HTTP_REMOTE_ORIGIN +
new URL("resources/", self.location).pathname +
"show-picker-child-iframe.html?documentDomain=" + get_host_info().ORIGINAL_HOST;

// Wait for the iframe to report security errors when calling showPicker().
const securityErrors = await waitForSecurityErrors();
assert_equals(
securityErrors,
"select",
"In cross-origin but same-origin-domain iframes, showPicker() throws a SecurityError."
);
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<title>Test showPicker() disabled requirement</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<select id="select" disabled>
<option>Item 1</option>
</select>
<script>
test(() => {
assert_throws_dom('InvalidStateError', () => { select.showPicker(); });
}, 'select showPicker() throws when disabled');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<title>Test showPicker() on multiple selects</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<select id="select" multiple>
<option>Item 1</option>
</select>
<script>
promise_test(async t => {
await test_driver.bless('show picker');
select.showPicker();
select.blur();
}, `select showPicker() does not throw when called on a <select multiple>`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<title>Test showPicker() on sized selects</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<select id="select" size="4">
<option>Item 1</option>
</select>
<script>
promise_test(async t => {
await test_driver.bless('show picker');
select.showPicker();
select.blur();
}, `select showPicker() does not throw when called on a <select size="4">`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<title>Test showPicker() user gesture requirement</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body></body>
<script type=module>
test(() => {
const select = document.createElement("select");

assert_throws_dom('NotAllowedError', () => { select.showPicker(); });
}, `select showPicker() requires a user gesture`);

promise_test(async t => {
const select = document.createElement("select");

await test_driver.bless('show picker');
select.showPicker();
select.blur();
}, `select showPicker() does not throw when user activation is active`);
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/reset-algorithm-rendering-expected.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/reset-algorithm-rendering-ref.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/reset-algorithm-rendering.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-add-optgroup.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-add-option-crash.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-add.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-ask-for-reset.html
Expand All @@ -31,4 +32,10 @@ List of files:
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-setcustomvalidity.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-validity.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-value.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/select-willvalidate-readonly-attribute.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/selected-index.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-cross-origin-iframe.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-disabled.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-multiple.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-size.tentative.html
/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-user-gesture.tentative.html
9 changes: 9 additions & 0 deletions LayoutTests/tests-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -3968,6 +3968,15 @@
"imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker.html": [
"slow"
],
"imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-multiple.tentative.html": [
"slow"
],
"imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-size.tentative.html": [
"slow"
],
"imported/w3c/web-platform-tests/html/semantics/forms/the-select-element/show-picker-user-gesture.tentative.html": [
"slow"
],
"imported/w3c/web-platform-tests/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener.html": [
"slow"
],
Expand Down

0 comments on commit d8c00ef

Please sign in to comment.