Import autofocus Web Platform Tests
authorajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Oct 2019 13:56:50 +0000 (13:56 +0000)
committerajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Oct 2019 13:56:50 +0000 (13:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202641

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Import web platform tests for autofocus, and remove duplicated test from
http/wpt/html/semantics/forms/autofocus.

* resources/import-expectations.json:
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus-expected.txt: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub-expected.txt.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus.html: Copied from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub.html.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-autofocus.html: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/resources/child-autofocus.html.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css: Added.
(#first):
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js: Added.
(waitForEvent):
(timeOut):
(async.waitUntilStableAutofocusState):
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/w3c-import.log: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub.html.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html: Added.
* web-platform-tests/html/interaction/focus/the-autofocus-attribute/w3c-import.log: Added.

LayoutTests:

* platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.
* platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250823 268f45cc-cd09-0410-ab3c-d52691b4dbfc

52 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus-expected.txt [moved from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub-expected.txt with 100% similarity]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus.html [moved from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub.html with 91% similarity]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-autofocus.html [moved from LayoutTests/http/wpt/html/semantics/forms/autofocus/resources/child-autofocus.html with 100% similarity]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/w3c-import.log [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/w3c-import.log [new file with mode: 0644]
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt [new file with mode: 0644]

index a29ebe4..dcf94cb 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-08  Ali Juma  <ajuma@chromium.org>
+
+        Import autofocus Web Platform Tests
+        https://bugs.webkit.org/show_bug.cgi?id=202641
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.
+        * platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.
+
 2019-10-08  Antti Koivisto  <antti@apple.com>
 
         [CSS Shadow Parts] Implement style invalidation
index 564f693..31b7229 100644 (file)
@@ -1,3 +1,66 @@
+2019-10-08  Ali Juma  <ajuma@chromium.org>
+
+        Import autofocus Web Platform Tests
+        https://bugs.webkit.org/show_bug.cgi?id=202641
+
+        Reviewed by Ryosuke Niwa.
+
+        Import web platform tests for autofocus, and remove duplicated test from
+        http/wpt/html/semantics/forms/autofocus.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus-expected.txt: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub-expected.txt.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus.html: Copied from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub.html.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-autofocus.html: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/resources/child-autofocus.html.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css: Added.
+        (#first):
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js: Added.
+        (waitForEvent):
+        (timeOut):
+        (async.waitUntilStableAutofocusState):
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/w3c-import.log: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html: Renamed from LayoutTests/http/wpt/html/semantics/forms/autofocus/no-cross-origin-autofocus.sub.html.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html: Added.
+        * web-platform-tests/html/interaction/focus/the-autofocus-attribute/w3c-import.log: Added.
+
 2019-10-08  Rob Buis  <rbuis@igalia.com>
 
         Fetch: data: URL HEAD request should result in empty response body
index c5978b0..9eb9d43 100644 (file)
     "web-platform-tests/html/iana": "skip", 
     "web-platform-tests/html/infrastructure": "skip", 
     "web-platform-tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers": "skip", 
+    "web-platform-tests/html/interaction/focus/the-autofocus-attribute": "import", 
     "web-platform-tests/html/obsolete": "skip", 
     "web-platform-tests/html/rendering": "skip", 
     "web-platform-tests/html/semantics/document-metadata/the-meta-element/pragma-directives": "skip", 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document-expected.txt
new file mode 100644 (file)
index 0000000..96fdb73
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Autofocus element in not-fully-active document should not be queued. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html
new file mode 100644 (file)
index 0000000..a26a44d
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  let doc = document.cloneNode(false);
+  doc.appendChild(doc.createElement('html'))
+  doc.firstChild.innerHTML = '<body><input autofocus/></body>';
+  await waitUntilStableAutofocusState();
+  assert_equals(doc.activeElement, doc.body);
+}, 'Autofocus element in not-fully-active document should not be queued.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document-expected.txt
new file mode 100644 (file)
index 0000000..f4de025
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS Autofocus should work if an element with autofocus is inserted into a document which was loaded some time ago. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html
new file mode 100644 (file)
index 0000000..47e3e3f
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<body>
+<script>
+'use strict';
+
+promise_test(async t => {
+  await waitForLoad(window);
+  await timeOut(t, 1000);
+  let element = document.createElement('input');
+  element.autofocus = true;
+  document.body.appendChild(element);
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, element);
+}, 'Autofocus should work if an element with autofocus is inserted into a ' +
+    'document which was loaded some time ago.');
+</script>
+</body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt
new file mode 100644 (file)
index 0000000..ca37adc
--- /dev/null
@@ -0,0 +1,4 @@
+
+FAIL The first autofocus element in the document should win. assert_equals: expected Element node <input autofocus=""></input> but got Element node <input autofocus=""></input>
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected-expected.txt
new file mode 100644 (file)
index 0000000..fc90800
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS The second autofocus element wins if the first autofocus element was disconnected and reconnected before flushing the autofocus candidates. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html
new file mode 100644 (file)
index 0000000..99ee919
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<input autofocus id="i1">
+<input autofocus id="i2">
+<script>
+"use strict";
+
+promise_test(async () => {
+  const input1 = document.querySelector("#i1");
+  const input2 = document.querySelector("#i2");
+  input1.remove();
+  input2.parentNode.insertBefore(input1, input2);
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, input2);
+}, 'The second autofocus element wins if the first autofocus element was ' +
+   'disconnected and reconnected before flushing the autofocus candidates.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before-expected.txt
new file mode 100644 (file)
index 0000000..c6266f2
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS The temporally first autofocus in the document wins, even if an element is inserted later that is previous in the document tree. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html
new file mode 100644 (file)
index 0000000..f361463
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>The temporally first autofocus in the document wins, even if an element is inserted later that is previous in the document tree</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
+<link rel="author" title="Domenic Denicola" href="d@domenic.me">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<input autofocus>
+
+<script>
+"use strict";
+
+promise_test(async () => {
+  const input1 = document.querySelector("input");
+  const input2 = document.createElement("input");
+  input2.autofocus = true;
+  document.body.prepend(input2);
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, input1);
+  assert_not_equals(document.activeElement, input2);
+}, 'The temporally first autofocus in the document wins, even if an element is inserted later that is previous in the document tree.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt
new file mode 100644 (file)
index 0000000..d028309
--- /dev/null
@@ -0,0 +1,4 @@
+  
+
+FAIL The first autofocus in the document wins, even if elements are inserted later. assert_equals: expected Element node <input autofocus=""></input> but got Element node <input autofocus=""></input>
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html
new file mode 100644 (file)
index 0000000..1d64b86
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>The first autofocus in the document wins, even if elements are inserted later</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
+<link rel="author" title="Domenic Denicola" href="d@domenic.me">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<input autofocus>
+
+<script>
+"use strict";
+
+promise_test(async () => {
+  const input1 = document.querySelector("input");
+  const input2 = document.createElement("input");
+  input2.autofocus = true;
+  document.body.appendChild(input2);
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, input1);
+  assert_not_equals(document.activeElement, input2);
+}, 'The first autofocus in the document wins, even if elements are inserted later.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html
new file mode 100644 (file)
index 0000000..02ebb79
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>The first autofocus in the document wins</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
+<link rel="author" title="Domenic Denicola" href="d@domenic.me">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<input autofocus>
+<input autofocus>
+
+<script>
+"use strict";
+
+promise_test(async () => {
+  const [input1, input2] = document.querySelectorAll("input");
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, input1);
+  assert_not_equals(document.activeElement, input2);
+}, 'The first autofocus element in the document should win.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document-expected.txt
new file mode 100644 (file)
index 0000000..0b1898d
--- /dev/null
@@ -0,0 +1,4 @@
+  
+
+FAIL If topDocument's focused area is not topDocument, autofocus is not processed. assert_equals: activeElement should not be changed expected Element node <iframe srcdoc="<input><script>document.querySelector('in... but got Element node <input autofocus=""></input>
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html
new file mode 100644 (file)
index 0000000..327040e
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<iframe srcdoc="<input><script>document.querySelector('input').focus();</script>"></iframe>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  await waitForLoad(window);
+  let iframe = document.querySelector('iframe');
+  assert_equals(document.activeElement, iframe, 'Prereq: IFRAME should be focused');
+
+  let input = document.createElement('input');
+  input.autofocus = true;
+  document.body.appendChild(input);
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, iframe, 'activeElement should not be changed');
+  assert_not_equals(document.activeElement, input);
+}, 'If topDocument\'s focused area is not topDocument, autofocus is not processed.');
+</script>
@@ -37,7 +37,7 @@
         }
       }));
       document.getElementById("child").src =
-          get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/html/semantics/forms/autofocus/resources/child-autofocus.html";
+          get_host_info().HTTP_REMOTE_ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/child-autofocus.html";
     }, "Autofocus shouldn't work in cross-origin iframe");
   </script>
 </body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features-expected.txt
new file mode 100644 (file)
index 0000000..eb74fe3
--- /dev/null
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: Blocked autofocusing on a form control because the form's frame is sandboxed and the 'allow-scripts' permission is not set.
+
+
+PASS If the sandboxed automatic features browsing context flag is set, autofocus in the browsing context should not be handled. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html
new file mode 100644 (file)
index 0000000..991373d
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<iframe sandbox srcdoc="<input autofocus>"></iframe>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  await waitForLoad(window);
+  await waitUntilStableAutofocusState();
+  assert_not_equals(document.activeElement, document.querySelector('iframe'));
+}, 'If the sandboxed automatic features browsing context flag is set, ' +
+    'autofocus in the browsing context should not be handled.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task-expected.txt
new file mode 100644 (file)
index 0000000..7d8b53e
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS The element is not focused during the initial parsing task 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html
new file mode 100644 (file)
index 0000000..50efc17
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>The element is not focused during the initial parsing task</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
+<link rel="author" title="Domenic Denicola" href="d@domenic.me">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<input autofocus>
+<input autofocus>
+
+<script>
+"use strict";
+
+const input = document.querySelector("input");
+
+assert_equals(document.activeElement, document.body);
+assert_not_equals(document.activeElement, input);
+
+done();
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt
new file mode 100644 (file)
index 0000000..d36d3f2
--- /dev/null
@@ -0,0 +1,4 @@
+
+FAIL If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused. assert_equals: expected Element node <textarea autofocus=""></textarea> but got Element node <select autofocus=""></select>
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html
new file mode 100644 (file)
index 0000000..e3b5560
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<textarea autofocus disabled></textarea>
+<select autofocus></select>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  const [textarea, select] = document.querySelectorAll('[autofocus]');
+  textarea.disabled = false;
+
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, textarea);
+  assert_not_equals(document.activeElement, select);
+}, 'If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html
new file mode 100644 (file)
index 0000000..f60acfc
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src="/common/get-host-info.sub.js"></script>
+<iframe id="iframe" width="200" height="100"></iframe>
+
+<script>
+  iframe.src =
+    get_host_info().ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html";
+  window.addEventListener("message", event => {
+    if (event.data == "grand_child_loaded") {
+      parent.postMessage("ready", "*");
+    } else if (event.data == "report_focus_state") {
+      frames[0].postMessage("report_focus_state", "*");
+    } else if (event.data == "grand_child_is_focused" ||
+               event.data == "grand_child_is_not_focused") {
+      parent.postMessage(event.data, "*");
+    }
+  });
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css
new file mode 100644 (file)
index 0000000..bbbcf79
--- /dev/null
@@ -0,0 +1,3 @@
+#first {
+  display: none;
+}
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html
new file mode 100644 (file)
index 0000000..985cba4
--- /dev/null
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<body>
+<div id="anchor1"></div>
+<input autofocus>
+</body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html
new file mode 100644 (file)
index 0000000..88be6e0
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<input id="target" value="This should be focused!" autofocus></input>
+
+<script>
+  let got_focus = false;
+  target.addEventListener("focus", () => got_focus = true);
+
+  window.addEventListener("load", () => {
+    parent.postMessage("grand_child_loaded", "*");
+  });
+
+  window.addEventListener("message", event => {
+    if (event.data == "report_focus_state") {
+      let msg = got_focus ? "grand_child_is_focused" : "grand_child_is_not_focused";
+      parent.postMessage(msg, "*");
+    }
+  });
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html
new file mode 100644 (file)
index 0000000..fc6c298
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<body>
+<script>
+const input = document.createElement('input');
+input.autofocus = true;
+document.body.appendChild(input);
+input.autofocus = false;
+window.opener.document.body.appendChild(input);
+</script>
+</body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js
new file mode 100644 (file)
index 0000000..0eeb5a9
--- /dev/null
@@ -0,0 +1,42 @@
+'use strict';
+
+function waitForEvent(target, type, options) {
+  return new Promise((resolve, reject) => {
+    target.addEventListener(type, resolve, options);
+  });
+}
+
+function waitForAnimationFrame(w) {
+  let targetWindow = w || window;
+  return new Promise((resolve, reject) => {
+    targetWindow.requestAnimationFrame(resolve);
+  });
+}
+
+function waitForEvent(target, type, options) {
+  return new Promise((resolve, reject) => {
+    target.addEventListener(type, resolve, options);
+  });
+}
+
+function waitForLoad(target) {
+  return waitForEvent(target, 'load');
+}
+
+function timeOut(test, ms) {
+  return new Promise((resolve, reject) => {
+    test.step_timeout(resolve, ms);
+  });
+}
+
+// If an element with autofocus is connected to a document and this function
+// is called, the autofocus result is deterministic after returning from the
+// function.
+// Exception: If the document has script-blocking style sheets, this function
+// doesn't work well.
+async function waitUntilStableAutofocusState(w) {
+  let targetWindow = w || window;
+  // Awaiting two animation frames is an easy way to determine autofocus state.
+  await waitForAnimationFrame(targetWindow);
+  await waitForAnimationFrame(targetWindow);
+}
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/w3c-import.log
new file mode 100644 (file)
index 0000000..26dd677
--- /dev/null
@@ -0,0 +1,23 @@
+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/interaction/focus/the-autofocus-attribute/resources/child-autofocus.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/erase-first.css
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/frame-with-autofocus-element.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/resources/utils.js
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus-expected.txt
new file mode 100644 (file)
index 0000000..6f9f95e
--- /dev/null
@@ -0,0 +1,6 @@
+Autofocus should work in the same origin grand child iframe.
+
+
+
+PASS Autofocus should work in the same origin grand child iframe 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html
new file mode 100644 (file)
index 0000000..6e67aa6
--- /dev/null
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+<meta charset=utf-8>
+<meta name="assert" content="`autofocus` should work in the same origin iframe even if there is a cross-origin iframe between the parent and the same origin iframe">
+<title>autofocus in the same origin grand child iframe</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>
+<script src="/common/get-host-info.sub.js"></script>
+</head>
+<body>
+  <h1>Autofocus should work in the same origin grand child iframe.</h1>
+  <iframe id="child" width="200" height="100"></iframe>
+  <script>
+    let parent_loaded = false;
+    let grand_child_loaded = false;
+
+    async_test(function(t) {
+      function pingChildIfBothFramesLoaded() {
+        if (parent_loaded && grand_child_loaded)
+          frames[0].postMessage("report_focus_state", "*");
+      }
+
+      window.addEventListener("load", t.step_func(event => {
+        parent_loaded = true;
+        pingChildIfBothFramesLoaded();
+      }));
+
+      window.addEventListener("message", t.step_func(event => {
+        if (event.data == "ready") {
+          grand_child_loaded = true;
+          pingChildIfBothFramesLoaded();
+        } else if (event.data == "grand_child_is_focused") {
+          t.done();
+        } else if (event.data == "grand_child_is_not_focused") {
+          assert_unreached("The iframe shouldn't get focus");
+        }
+      }));
+      document.getElementById("child").src =
+          get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html";
+    }, "Autofocus should work in the same origin grand child iframe");
+  </script>
+</body>
+</html>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context-expected.txt
new file mode 100644 (file)
index 0000000..5d2b7b1
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS Autofocus elements queued in another top-level browsing context's documents should be skipped. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html
new file mode 100644 (file)
index 0000000..d392b90
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+<script>
+'use strict';
+
+promise_test(async () => {
+  let w = window.open('resources/moving-autofocus-to-parent.html');
+  await waitForLoad(w);
+  await waitUntilStableAutofocusState(w);
+  assert_equals(w.document.activeElement, w.document.body);
+  assert_equals(document.activeElement, document.body);
+  w.close();
+}, 'Autofocus elements queued in another top-level browsing context\'s ' +
+   'documents should be skipped.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment-expected.txt
new file mode 100644 (file)
index 0000000..c83bef0
--- /dev/null
@@ -0,0 +1,9 @@
+
+FAIL Autofocus elements in iframed documents with URL fragments should be skipped. assert_equals: Autofocus elements in iframes should not be focused. expected Element node <body><iframe src="resources/frame-with-autofocus-element... but got Element node <iframe src="resources/frame-with-autofocus-element.html#...
+FAIL Autofocus elements in top-level browsing context's documents with URI fragments should be skipped. assert_equals: expected Element node <body>
+<div id="anchor1"></div>
+<input autofocus="">
+
+</b... but got Element node <input autofocus=""></input>
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html
new file mode 100644 (file)
index 0000000..a4301e1
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<iframe src="resources/frame-with-autofocus-element.html#anchor1"></iframe>
+<iframe src="resources/frame-with-autofocus-element.html#non-existent-anchor"></iframe>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  await waitForLoad(window);
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, document.body,
+      'Autofocus elements in iframes should not be focused.');
+
+  let input = document.createElement('input');
+  input.autofocus = true;
+  document.body.appendChild(input);
+  await waitUntilStableAutofocusState();
+  assert_equals(document.activeElement, input);
+}, 'Autofocus elements in iframed documents with URL fragments should be skipped.');
+
+promise_test(async () => {
+  let w = window.open('resources/frame-with-autofocus-element.html#xpointer(//body)');
+  await waitForLoad(w);
+  await waitUntilStableAutofocusState(w);
+  assert_equals(w.document.activeElement, w.document.body);
+  w.close();
+}, 'Autofocus elements in top-level browsing context\'s documents with URI fragments should be skipped.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable-expected.txt
new file mode 100644 (file)
index 0000000..a05d385
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS Non-focusable autofocus element is skipped. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html
new file mode 100644 (file)
index 0000000..008371d
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<textarea autofocus disabled></textarea>
+<select autofocus></select>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  const [textarea, select] = document.querySelectorAll('[autofocus]');
+
+  await waitUntilStableAutofocusState();
+  assert_not_equals(document.activeElement, textarea);
+  assert_equals(document.activeElement, select);
+}, 'Non-focusable autofocus element is skipped.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active-expected.txt
new file mode 100644 (file)
index 0000000..d0fc0d6
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Autofocus element in not-fully-active document should be skipped while flusing. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html
new file mode 100644 (file)
index 0000000..fa5b608
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<iframe srcdoc="<input autofocus><script>window.frameElement.remove();</script>"></iframe>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  let iframe = document.querySelector('iframe');
+  let iframeDocument = iframe.contentDocument;
+  await waitForLoad(window);
+  assert_not_equals(document.activeElement, iframe);
+  assert_equals(iframeDocument.activeElement, iframeDocument.body);
+}, 'Autofocus element in not-fully-active document should be skipped while flusing.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet-expected.txt
new file mode 100644 (file)
index 0000000..10a02a2
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+PASS Script-blocking style sheet should pause flushing autofocus candidates. 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html
new file mode 100644 (file)
index 0000000..22a4c35
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+<link rel="stylesheet" href="resources/erase-first.css?pipe=trickle(d1)">
+
+<input id="first" autofocus>
+<input id="second" autofocus>
+
+<script>
+'use strict';
+
+promise_test(async () => {
+  await waitForEvent(document.body, 'focus', {capture:true});
+  assert_equals(document.activeElement.id, 'second');
+}, 'Script-blocking style sheet should pause flushing autofocus candidates.');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt
new file mode 100644 (file)
index 0000000..e802650
--- /dev/null
@@ -0,0 +1,5 @@
+
+FAIL Contenteditable element should support autofocus assert_equals: expected "DIV" but got "BODY"
+FAIL Element with tabindex should support autofocus assert_equals: expected "SPAN" but got "BODY"
+PASS Non-HTMLElement should not support autofocus 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html
new file mode 100644 (file)
index 0000000..7619367
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+<script>
+"use strict";
+
+promise_test(async t => {
+  let w = window.open('/common/blank.html');
+  await waitForLoad(w);
+  t.add_cleanup(() => { w.close(); });
+  w.document.body.innerHTML = '<div contenteditable=true autofocus></div>';
+  await waitUntilStableAutofocusState(w);
+  assert_equals(w.document.activeElement.tagName, 'DIV');
+}, 'Contenteditable element should support autofocus');
+
+promise_test(async t => {
+  let w = window.open('/common/blank.html');
+  await waitForLoad(w);
+  t.add_cleanup(() => { w.close(); });
+  w.document.body.innerHTML = '<span tabindex=0 autofocus></span>';
+  await waitUntilStableAutofocusState(w);
+  assert_equals(w.document.activeElement.tagName, 'SPAN');
+}, 'Element with tabindex should support autofocus');
+
+promise_test(async t => {
+  let w = window.open('/common/blank.html');
+  await waitForLoad(w);
+  t.add_cleanup(() => { w.close(); });
+  let element = w.document.createElementNS('uri1', 'prefix:local');
+  element.setAttribute('autofocus', '');
+  w.document.body.appendChild(element);
+  await waitUntilStableAutofocusState(w);
+  assert_equals(w.document.activeElement.tagName, 'BODY');
+}, 'Non-HTMLElement should not support autofocus');
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt
new file mode 100644 (file)
index 0000000..13541f6
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+FAIL "Flush autofocus candidates" should be happen after the first animation frame callbacks, and before a resize event in the next iteration of window event loop. assert_array_equals: lengths differ, expected 3 got 4
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html
new file mode 100644 (file)
index 0000000..afaf092
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://html.spec.whatwg.org/C/#update-the-rendering">
+
+<body>
+<script>
+'use strict';
+
+async_test(t => {
+  t.events = [];
+
+  let iframe = document.createElement('iframe');
+  iframe.addEventListener('load', t.step_func(() => {
+    let w = iframe.contentWindow;
+    w.requestAnimationFrame(t.step_func(() => {
+      t.events.push('animationFrame');
+      w.requestAnimationFrame(t.step_func(() => {
+        t.events.push('animationFrame-should-not-be-recorded');
+      }));
+    }));
+    let element = w.document.createElement('input');
+    element.autofocus = true;
+    element.addEventListener('focus', t.step_func(() => {
+      t.events.push('autofocus');
+      iframe.style.width = '71px';
+    }));
+
+    w.addEventListener('resize', t.step_func_done(() => {
+      t.events.push('resize');
+      assert_array_equals(t.events, ['animationFrame', 'autofocus', 'resize']);
+    }));
+
+    w.document.body.appendChild(element);
+  }));
+  document.body.appendChild(iframe);
+}, '"Flush autofocus candidates" should be happen after the first animation ' +
+    'frame callbacks, and before a resize event in the next iteration of ' +
+    'window event loop.');
+</script>
+</body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/w3c-import.log
new file mode 100644 (file)
index 0000000..fef7bde
--- /dev/null
@@ -0,0 +1,35 @@
+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/interaction/focus/the-autofocus-attribute/autofocus-in-not-fully-active-document.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-but-before.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-cross-origin-autofocus.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/no-sandboxed-automatic-features.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/not-on-first-task.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/same-origin-autofocus.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-another-top-level-browsing-context.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-document-with-fragment.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-non-focusable.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/skip-not-fully-active.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/spin-by-blocking-style-sheet.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/supported-elements.html
+/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html
diff --git a/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt b/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt
new file mode 100644 (file)
index 0000000..3294a0d
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+FAIL "Flush autofocus candidates" should be happen after the first animation frame callbacks, and before a resize event in the next iteration of window event loop. assert_array_equals: property 0, expected "animationFrame" but got "autofocus"
+
diff --git a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt b/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt
new file mode 100644 (file)
index 0000000..fd49151
--- /dev/null
@@ -0,0 +1,4 @@
+
+
+FAIL "Flush autofocus candidates" should be happen after the first animation frame callbacks, and before a resize event in the next iteration of window event loop. assert_array_equals: lengths differ, expected 3 got 2
+