Bug 1508207 [wpt PR 14120] - Various fixes to complete-method-manual.https.html, a=testonly
authorMarcos Cáceres <marcos@marcosc.com>
Thu, 22 Nov 2018 10:33:56 +0000
changeset 507116 5ac1a86bd492464eed245a53e93d8f2af2e7db7a
parent 507115 0f18b7b652c4cf53ae51cc999bfd22882f7b4561
child 507117 7433f8fac49ab00d576e5ddb4b6d529a67b59478
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1508207, 14120
milestone65.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 1508207 [wpt PR 14120] - Various fixes to complete-method-manual.https.html, a=testonly Automatic update from web-platform-testsVarious fixes to complete-method-manual.https.html (#14120) * fix: variables are out of scope * Add explicit done button * fix: test unknown and missing value correctly * relocate code comment -- wpt-commits: 519461c331ab6656d1c28d9d6db465b5cec89224 wpt-pr: 14120
testing/web-platform/tests/payment-request/payment-response/complete-method-manual.https.html
--- a/testing/web-platform/tests/payment-request/payment-response/complete-method-manual.https.html
+++ b/testing/web-platform/tests/payment-request/payment-response/complete-method-manual.https.html
@@ -7,46 +7,49 @@
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="helpers.js"></script>
 <script>
 async function runManualTest({ completeWith: result }, button) {
   button.disabled = true;
   const { response, request } = await getPaymentRequestResponse();
   promise_test(async t => {
+    let completePromise;
+    let invalidComplete;
+    let afterComplete;
     try {
       // We .complete() as normal, using the passed test value
-      const completePromise = response.complete(result);
+      completePromise = response.complete(result);
       assert_true(completePromise instanceof Promise, "returns a promise");
       // Immediately calling complete() again yields a rejected promise.
-      const invalidComplete = response.complete(result);
+      invalidComplete = response.complete(result);
       await promise_rejects(t, "InvalidStateError", invalidComplete);
       // but the original promise is unaffected
       const returnedValue = await completePromise;
       assert_equals(
         returnedValue,
         undefined,
         "Returned value must always be undefined"
       );
       // We now call .complete() again, to force an exception
       // because [[complete]] is true.
-      const afterComplete = response.complete(result);
+      afterComplete = response.complete(result);
       await promise_rejects(t, "InvalidStateError", afterComplete);
       button.innerHTML = `✅  ${button.textContent}`;
     } catch (err) {
       button.innerHTML = `❌  ${button.textContent}`;
       assert_unreached("Unexpected exception: " + err.message);
     }
     const allPromises = new Set([
       completePromise,
       invalidComplete,
       afterComplete,
     ]);
     assert_equals(
-      allPromises.length,
+      allPromises.size,
       3,
       "Calling complete() multiple times is always a new object."
     );
   }, button.textContent.trim());
 }
 </script>
 
 <h2>
@@ -63,28 +66,36 @@ async function runManualTest({ completeW
 <ol>
   <li>
     <button onclick="runManualTest({completeWith: 'success'}, this)">
       If the value of the internal slot [[completeCalled]] is true,
       reject promise with an "InvalidStateError" DOMException.
     </button>
   </li>
   <li>
-    <button onclick="runManualTest({completeWith: 'unknown'}, this)">
+    <button onclick="runManualTest({completeWith: undefined}, this)">
       Passing no argument defaults to "unknown",
       eventually closing the sheet and doesn't throw.
     </button>
   </li>
   <li>
     <button onclick="runManualTest({completeWith: 'success'}, this)">
       Passing "success" eventually closes the sheet and doesn't throw.
     </button>
   </li>
   <li>
-    <button onclick="runManualTest({completeWith: 'fail'}, this).then(done)">
+    <button onclick="runManualTest({completeWith: 'fail'}, this)">
       Passing "fail" eventually closes the sheet and doesn't throw.
     </button>
   </li>
+  <li>
+    <button onclick="runManualTest({completeWith: 'unknown'}, this)">
+      Passing "unknown" eventually closes the sheet and doesn't throw.
+    </button>
+  </li>
+  <li>
+    <button onclick="done()">Done!</button>
+  </li>
 </ol>
 <small>
   If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a>
   and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>.
 </small>