Bug 1513136 [wpt PR 14443] - Async Clipboard: Update tests to use async/await syntax, a=testonly
authorDarwin Huang <huangdarwin@chromium.org>
Wed, 19 Dec 2018 11:04:53 +0000
changeset 514988 e9762abb04f16ad2477db7c535d45a0844b58631
parent 514987 d8d39489c8e7849f1f5fa01159f31b824b1914fe
child 514989 8fb8f380553e8a17991b4d9653ab98c07a0087cc
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1513136, 14443, 896479, 1371016, 615686
milestone66.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 1513136 [wpt PR 14443] - Async Clipboard: Update tests to use async/await syntax, a=testonly Automatic update from web-platform-tests Async Clipboard: Update tests to use async/await syntax Bug: 896479 Change-Id: I95b4c57b2643883f2ea7f0ebbea4f50d7bc7111a Reviewed-on: https://chromium-review.googlesource.com/c/1371016 Reviewed-by: Gary Kacmarcik <garykac@chromium.org> Commit-Queue: Darwin Huang <huangdarwin@chromium.org> Cr-Commit-Position: refs/heads/master@{#615686} -- wpt-commits: e26580600d344bcc8721d09f90c52aeb8b6c96fe wpt-pr: 14443
testing/web-platform/tests/clipboard-apis/async-write-dttext-read-dttext-manual.https.html
testing/web-platform/tests/clipboard-apis/async-write-dttext-read-text-manual.https.html
testing/web-platform/tests/clipboard-apis/async-write-text-read-dttext-manual.https.html
testing/web-platform/tests/clipboard-apis/async-write-text-read-text-manual.https.html
--- a/testing/web-platform/tests/clipboard-apis/async-write-dttext-read-dttext-manual.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-dttext-read-dttext-manual.https.html
@@ -1,30 +1,25 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Async Clipboard write (dt/text) -> read (dt/text) tests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-async_test(function(t) {
-  var test_data = "Clipboard write (dt/text) -> read (dt/text) test data";
-  var cb = navigator.clipboard;
-  var dt = new DataTransfer();
-  dt.items.add(test_data, "text/plain");
+promise_test(async (t) => {
+  const input = "Clipboard write (dt/text) -> read (dt/text) test data";
+  const dt = new DataTransfer();
+  dt.items.add(input, "text/plain");
 
-  cb.write(dt).then(t.step_func(() => {
-    cb.read().then(t.step_func((data) => {
-      assert_equals(data.items.length, 1);
-      data.items[0].getAsString(t.step_func((s) => {
-        assert_equals(s, test_data);
-        t.done();
-      }));
-    }), function() {
-      t.unreached_func("clipboard.read() fail");
-    });
-  }), function() {
-    t.unreached_func("clipboard.write() fail");
+  await navigator.clipboard.write(dt);
+  const output = await navigator.clipboard.read();
+
+  assert_equals(output.items.length, 1);
+  const result_promise = new Promise(resolve => {
+    output.items[0].getAsString(resolve);
   });
+  const string_output = await result_promise;
+  assert_equals(string_output, input);
 }, "Verify write and read clipboard (DataTransfer/text)");
 </script>
 Note: This is a manual test because it writes/reads to the shared system
 clipboard and thus cannot be run async with other tests that might interact
 with the clipboard.
--- a/testing/web-platform/tests/clipboard-apis/async-write-dttext-read-text-manual.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-dttext-read-text-manual.https.html
@@ -1,27 +1,20 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Async Clipboard write (dt/text) -> readText tests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-async_test(function(t) {
-  var test_data = "Clipboard write (dt/text) -> readText test data";
-  var cb = navigator.clipboard;
-  var dt = new DataTransfer();
-  dt.items.add(test_data, "text/plain");
+promise_test(async (t) => {
+  const input = "Clipboard write (dt/text) -> readText test data";
+  const dt = new DataTransfer();
+  dt.items.add(input, "text/plain");
 
-  cb.write(dt).then(t.step_func(() => {
-    cb.readText().then(t.step_func((data) => {
-      assert_equals(data, test_data);
-      t.done();
-    }), function() {
-      t.unreached_func("clipboard.read() fail");
-    });
-  }), function() {
-    t.unreached_func("clipboard.write() fail");
-  });
+  await navigator.clipboard.write(dt);
+  const output = await navigator.clipboard.readText();
+
+  assert_equals(output, input);
 }, "Verify write and read clipboard (DataTransfer/text)");
 </script>
 Note: This is a manual test because it writes/reads to the shared system
 clipboard and thus cannot be run async with other tests that might interact
 with the clipboard.
--- a/testing/web-platform/tests/clipboard-apis/async-write-text-read-dttext-manual.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-text-read-dttext-manual.https.html
@@ -1,27 +1,23 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Async Clipboard writeText -> read (dt/text) tests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-async_test(function(t) {
-  var test_data = "Clipboard writeText -> read(dt/text) test data";
-  var cb = navigator.clipboard;
-  cb.writeText(test_data).then(t.step_func(() => {
-    cb.read().then(t.step_func((data) => {
-      assert_equals(data.items.length, 1);
-      data.items[0].getAsString(t.step_func((s) => {
-        assert_equals(s, test_data);
-        t.done();
-      }));
-    }), function() {
-      t.unreached_func("clipboard.read() fail");
-    });
-  }), function() {
-    t.unreached_func("clipboard.writeText() fail");
+promise_test(async (t) => {
+  const input = "Clipboard writeText -> read (dt/text) test data";
+
+  await navigator.clipboard.writeText(input);
+  const output = await navigator.clipboard.read();
+
+  assert_equals(output.items.length, 1);
+  const result_promise = new Promise(resolve => {
+    output.items[0].getAsString(resolve);
   });
+  const string_output = await result_promise;
+  assert_equals(string_output, input);
 }, "Verify write and read clipboard (DOMString)");
 </script>
 Note: This is a manual test because it writes/reads to the shared system
 clipboard and thus cannot be run async with other tests that might interact
 with the clipboard.
--- a/testing/web-platform/tests/clipboard-apis/async-write-text-read-text-manual.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-write-text-read-text-manual.https.html
@@ -1,24 +1,18 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Async Clipboard writeText -> readText tests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-async_test(function(t) {
-  var test_data = "Clipboard writeText -> readText test data";
-  var cb = navigator.clipboard;
-  cb.writeText(test_data).then(t.step_func(() => {
-    cb.readText().then(t.step_func((data) => {
-      assert_equals(data, test_data);
-      t.done();
-    }), function() {
-      t.unreached_func("clipboard.readText() fail");
-    });
-  }), function() {
-    t.unreached_func("clipboard.writeText() fail");
-  });
+promise_test(async (t) => {
+  const input = "Clipboard writeText -> readText test data";
+
+  await navigator.clipboard.writeText(input);
+  const output = await navigator.clipboard.readText();
+
+  assert_equals(output, input);
 }, "Verify write and read clipboard (DOMString)");
 </script>
 Note: This is a manual test because it writes/reads to the shared system
 clipboard and thus cannot be run async with other tests that might interact
 with the clipboard.