Bug 1516476 [wpt PR 14675] - Async Clipboard: Refactor tests to use arrow functions, a=testonly
authorDarwin Huang <huangdarwin@chromium.org>
Thu, 31 Jan 2019 15:16:49 +0000
changeset 457817 729c00cd7f0e595aacfa938350f9c3d28a7eb7a6
parent 457816 979e0fb67023d17a496eced86fdfdfb48c27812d
child 457818 819fa77c9b40269c525b6143d0c0a5f2b63826f0
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1516476, 14675, 896479, 1391408, 618984
milestone67.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 1516476 [wpt PR 14675] - Async Clipboard: Refactor tests to use arrow functions, a=testonly Automatic update from web-platform-tests Async Clipboard: Refactor tests to use arrow functions Bug: 896479 Change-Id: I2a9cd18fa812ff9bd9f8b51923b4fe373f593582 Reviewed-on: https://chromium-review.googlesource.com/c/1391408 Commit-Queue: Darwin Huang <huangdarwin@chromium.org> Reviewed-by: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#618984} -- wpt-commits: f74e788a986b4630f12fdf5f1aeba913b6328cad wpt-pr: 14675
testing/web-platform/tests/clipboard-apis/async-interfaces.https.html
testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
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
testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html
--- a/testing/web-platform/tests/clipboard-apis/async-interfaces.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-interfaces.https.html
@@ -5,32 +5,32 @@
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <script src=/resources/WebIDLParser.js></script>
 <script src=/resources/idlharness.js></script>
 <script>
 'use strict';
 
 function doTest(idl, dom) {
-  var idl_array = new IdlArray();
+  const idl_array = new IdlArray();
   idl_array.add_untested_idls('interface Navigator {};');
   idl_array.add_untested_idls('interface EventTarget {};');
   idl_array.add_untested_idls('dictionary PermissionDescriptor {};');
   idl_array.add_untested_idls(dom, { only: ['Event', 'EventInit'] });
   idl_array.add_idls(idl);
   idl_array.add_objects({
     Navigator: ['navigator'],
     Clipboard: ['navigator.clipboard'],
     ClipboardEvent: ['new ClipboardEvent("x")'],
   });
   idl_array.test();
 };
 
 function fetchText(url) {
-  return fetch(url).then((response) => response.text());
+  return fetch(url).then(response => response.text());
 }
 
 promise_test(() => {
   return Promise.all(
     [
       "/interfaces/clipboard-apis.idl",
       "/interfaces/dom.idl",
     ].map(fetchText))
--- a/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
+++ b/testing/web-platform/tests/clipboard-apis/async-navigator-clipboard-basics.https.html
@@ -1,69 +1,69 @@
 <!DOCTYPE html>
 <meta charset="utf-8">
 <title>Async Clipboard basic tests</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
 
-test(function() {
+test(() => {
   assert_not_equals(navigator.clipboard, undefined);
   assert_true(navigator.clipboard instanceof Clipboard);
   assert_equals(navigator.clipboard, navigator.clipboard);
 }, "navigator.clipboard exists");
 
 /* clipboard.write() */
 
-promise_test(function() {
-  var dt = new DataTransfer();
+promise_test(() => {
+  const dt = new DataTransfer();
   dt.items.add("Howdy", "text/plain");
   return navigator.clipboard.write(dt);
 }, "navigator.clipboard.write(DataTransfer) succeeds");
 
-promise_test(function(t) {
+promise_test(t => {
   return promise_rejects(t, new TypeError(),
                          navigator.clipboard.write());
 }, "navigator.clipboard.write() fails (expect DataTransfer)");
 
-promise_test(function(t) {
+promise_test(t => {
   return promise_rejects(t, new TypeError(),
                          navigator.clipboard.write(null));
 }, "navigator.clipboard.write(null) fails (expect DataTransfer)");
 
-promise_test(function(t) {
+promise_test(t => {
   return promise_rejects(t, new TypeError(),
                          navigator.clipboard.write("Bad string"));
 }, "navigator.clipboard.write(DOMString) fails (expect DataTransfer)");
 
 
 /* clipboard.writeText() */
 
-promise_test(function() {
+promise_test(() => {
   return navigator.clipboard.writeText("New clipboard text");
 }, "navigator.clipboard.writeText(DOMString) succeeds");
 
-promise_test(function(t) {
+promise_test(t => {
   return promise_rejects(t, new TypeError(),
                          navigator.clipboard.writeText());
 }, "navigator.clipboard.writeText() fails (expect DOMString)");
 
 
 /* clipboard.read() */
 
-promise_test(function() {
+promise_test(() => {
   return navigator.clipboard.read()
-    .then(function(result) {
+    .then(result => {
       assert_true(result instanceof DataTransfer);
     });
 }, "navigator.clipboard.read() succeeds");
 
 
 /* clipboard.readText() */
 
-promise_test(function() {
+promise_test(() => {
   return navigator.clipboard.readText()
-    .then(function(result) {
+    .then(result => {
       assert_equals(typeof result, "string");
     });
 }, "navigator.clipboard.readText() succeeds");
 
 </script>
--- 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,15 +1,15 @@
 <!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>
-promise_test(async (t) => {
+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");
 
   await navigator.clipboard.write(dt);
   const output = await navigator.clipboard.read();
 
   assert_equals(output.items.length, 1);
--- 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,15 +1,15 @@
 <!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>
-promise_test(async (t) => {
+promise_test(async t => {
   const input = "Clipboard write (dt/text) -> readText test data";
   const dt = new DataTransfer();
   dt.items.add(input, "text/plain");
 
   await navigator.clipboard.write(dt);
   const output = await navigator.clipboard.readText();
 
   assert_equals(output, input);
--- 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,15 +1,15 @@
 <!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>
-promise_test(async (t) => {
+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);
--- 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,15 +1,15 @@
 <!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>
-promise_test(async (t) => {
+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>
--- a/testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html
+++ b/testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html
@@ -4,29 +4,29 @@
 <link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut">
 <link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id=log></div>
 <script>
 const EVENTS = [ 'copy', 'cut', 'paste' ];
 
+function testEvent(eventName, init, composed_flag_expectation, testName) {
+  async_test(test => {
+    document.addEventListener(eventName, test.step_func_done(e => {
+      assert_false(e.isTrusted, `synthetic ${eventName} event is untrusted`);
+      assert_equals(e.composed, composed_flag_expectation,
+                    `composed flag should be ${composed_flag_expectation}`);
+    }));
+    const event = new ClipboardEvent(eventName, init);
+    document.dispatchEvent(event);
+  }, testName);
+}
+
 EVENTS.forEach(name => {
-  function testEvent(name, init, composed_flag_expectation, name) {
-    async_test(function(test) {
-      document.addEventListener(name, test.step_func_done((e) => {
-        assert_false(e.isTrusted, `synthetic ${name} event is untrusted`);
-        assert_equals(e.composed, composed_flag_expectation,
-                      `composed flag should be ${composed_flag_expectation}`);
-      }));
-      let event = new ClipboardEvent(name, init);
-      document.dispatchEvent(event);
-    }, name);
-  }
-
-  testEvent(name, { bubbles: true, cancellable: true}, false,
+  testEvent(name, { bubbles: true, cancellable: true }, false,
             `Unspecified synthetic ${name} event should not be composed.`);
   testEvent(name, { bubbles: true, cancelable: true, composed: true }, true,
             `Synthetic ${name} event can be explicitly composed.`);
   testEvent(name, { bubbles: true, cancelable: true, composed: false }, false,
             `Synthetic ${name} event can be explicitly uncomposed.`);
 });
 </script>