Bug 1591650 [wpt PR 19916] - [infrastructure] Refactor tests & extend coverage, a=testonly
authorjugglinmike <mike@mikepennisi.com>
Mon, 04 Nov 2019 11:39:37 +0000
changeset 502949 225b21e209e564f981d3860c40b611d71fd0f2ab
parent 502948 d41d7ed78657efc7927efa44f999a73851d8fccf
child 502950 3ce646c363e070fb5f31757d0dc5472cfa8d980b
push id101053
push userwptsync@mozilla.com
push dateWed, 20 Nov 2019 11:26:19 +0000
treeherderautoland@3a7cd133fa3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1591650, 19916, 19449
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1591650 [wpt PR 19916] - [infrastructure] Refactor tests & extend coverage, a=testonly Automatic update from web-platform-tests [infrastructure] Refactor tests & extend coverage (#19916) testharness.js was recently extended with an API to explicitly opt-in to the "single page test" feature [1]. As per WPT RFC 28 [2], tests which do not use this API and which do not declare any subtests will soon be reported as a harness error. Update some tests which previously opted in implicitly to use the new API. Update others to instead declare a single subtest (so that they are no longer single-page tests). Add new tests to fully cover the conditions under which an uncaught exception or unhandled rejection could occur. [1] https://github.com/web-platform-tests/wpt/pull/19449 [2] https://github.com/web-platform-tests/rfcs/blob/master/rfcs/single_test.md -- wpt-commits: b00f6989a451cd003d04463a82918973fcd3fa53 wpt-pr: 19916 Differential Revision: https://phabricator.services.mozilla.com/D53571
testing/web-platform/tests/infrastructure/browsers/firefox/prefs.html
testing/web-platform/tests/infrastructure/expected-fail/uncaught-exception-following-subtest.html
testing/web-platform/tests/infrastructure/expected-fail/uncaught-exception-single-test.html
testing/web-platform/tests/infrastructure/expected-fail/unhandled-rejection-following-subtest.html
testing/web-platform/tests/infrastructure/expected-fail/unhandled-rejection-single-test.html
testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/uncaught-exception-following-subtest.html.ini
testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/uncaught-exception-single-test.html.ini
testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/unhandled-rejection-following-subtest.html.ini
testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/unhandled-rejection-single-test.html.ini
testing/web-platform/tests/infrastructure/testdriver/file_upload.sub.html
--- a/testing/web-platform/tests/infrastructure/browsers/firefox/prefs.html
+++ b/testing/web-platform/tests/infrastructure/browsers/firefox/prefs.html
@@ -1,8 +1,9 @@
 <title>Ensure that setting gecko prefs works</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-assert_equals(getComputedStyle(document.documentElement).color, "rgb(0, 255, 0)")
-done();
+test(function() {
+  assert_equals(getComputedStyle(document.documentElement).color, "rgb(0, 255, 0)")
+});
 </script>
 <p>This should be green</p>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/expected-fail/uncaught-exception-following-subtest.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Uncaught exception following subtest</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(function() {});
+throw new Error("error outside any setup or test");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/expected-fail/uncaught-exception-single-test.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Uncaught exception in single-page test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+setup({ single_test: true });
+throw new Error("error outside any setup or test");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/expected-fail/unhandled-rejection-following-subtest.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Unhandled rejection following subtest</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(function() {});
+Promise.reject(new Error("error outside any setup or test"));
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/expected-fail/unhandled-rejection-single-test.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Unhandled rejection in single-page test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+setup({ single_test: true });
+Promise.reject(new Error("error outside any setup or test"));
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/uncaught-exception-following-subtest.html.ini
@@ -0,0 +1,6 @@
+[uncaught-exception-following-subtest.html]
+  expected: ERROR
+
+  [Uncaught exception following subtest]
+    expected: PASS
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/uncaught-exception-single-test.html.ini
@@ -0,0 +1,4 @@
+[uncaught-exception-single-test.html]
+  [Uncaught exception in single-page test]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/unhandled-rejection-following-subtest.html.ini
@@ -0,0 +1,6 @@
+[unhandled-rejection-following-subtest.html]
+  expected: ERROR
+
+  [Unhandled rejection following subtest]
+    expected: PASS
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/infrastructure/metadata/infrastructure/expected-fail/unhandled-rejection-single-test.html.ini
@@ -0,0 +1,4 @@
+[unhandled-rejection-single-test.html]
+  [Unhandled rejection in single-page test]
+    expected: FAIL
+
--- a/testing/web-platform/tests/infrastructure/testdriver/file_upload.sub.html
+++ b/testing/web-platform/tests/infrastructure/testdriver/file_upload.sub.html
@@ -4,23 +4,23 @@
 <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>
 <form id="form">
   <input id="file_input" name="file_input" type="file">
 </form>
 <script>
-let form = document.getElementById("form");
-let input = document.getElementById("file_input");
-test_driver
-  .send_keys(input, "{{fs_path(file_upload_data.txt)}}")
-  .then(() =>
-    fetch("file_upload.py",
-      {method: "POST",
-       body: new FormData(form)}))
-   .then(response => response.text())
-   .then(data => {
-     assert_equals(data, "PASS");
-     done();
-   })
-   .catch(() => assert_unreached("File upload failed"));
+promise_test(() => {
+  let form = document.getElementById("form");
+  let input = document.getElementById("file_input");
+  return test_driver
+    .send_keys(input, "{{fs_path(file_upload_data.txt)}}")
+    .then(() =>
+      fetch("file_upload.py",
+        {method: "POST",
+         body: new FormData(form)}))
+     .then(response => response.text())
+     .then(data => {
+       assert_equals(data, "PASS");
+     });
+});
 </script>