summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js')
-rw-r--r--testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js
new file mode 100644
index 0000000000..c72ed7f19c
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/resources/common.js
@@ -0,0 +1,18 @@
+function waitUntilLoadedAndAutofocused() {
+ return new Promise(function(resolve) {
+ var loaded = false;
+ var autofocused = false;
+ window.addEventListener('load', function() {
+ loaded = true;
+ if (autofocused)
+ resolve();
+ }, false);
+ document.addEventListener('focusin', function() {
+ if (autofocused)
+ return;
+ autofocused = true;
+ if (loaded)
+ resolve();
+ }, false);
+ });
+} \ No newline at end of file