Bug 1486663 [wpt PR 12713] - Give more details when exception, a=testonly
authorMarcos Cáceres <marcos@marcosc.com>
Sat, 01 Sep 2018 00:39:40 +0000
changeset 434492 972ff5712d4ed980c6d1fb5bda21e30e00ed3371
parent 434491 69b98c18efc11813724e690b26bd3b9852b2c0f4
child 434493 4c7dca89ec35d0b244107fdeef12d1d4ca4c6e05
push id34563
push userdvarga@mozilla.com
push dateMon, 03 Sep 2018 21:54:32 +0000
treeherdermozilla-central@d14aaf65a80b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1486663, 12713
milestone63.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 1486663 [wpt PR 12713] - Give more details when exception, a=testonly Automatic update from web-platform-testsGive more details when exception (#12713) -- wpt-commits: eed07b8c0de42c2e42432febae2cd31a61a3d2b1 wpt-pr: 12713
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/payment-request/allowpaymentrequest/common.sub.js
testing/web-platform/tests/payment-request/allowpaymentrequest/echo-PaymentRequest.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -620547,21 +620547,21 @@
    "b100058cf9237e64d9e4319e3d639c00cf07633e",
    "testharness"
   ],
   "payment-request/allowpaymentrequest/basic.https.html": [
    "80a6a2279d72452611d0a009d017e6b24c6acbbe",
    "testharness"
   ],
   "payment-request/allowpaymentrequest/common.sub.js": [
-   "85a08461fcb0197ed2259d77035e696c1c69d6d8",
+   "a94bac064c9432980d437a98b72d4843f1b40bbe",
    "support"
   ],
   "payment-request/allowpaymentrequest/echo-PaymentRequest.html": [
-   "f18b16ee31bf7e3eb868d073ab5e0fb0061bbd88",
+   "5211c7e5ce78c0621036578fef79aeb2c98f2a27",
    "support"
   ],
   "payment-request/allowpaymentrequest/no-attribute-cross-origin-bc-containers.https.html": [
    "6919a54e2d2fabdb771a728e636ecdf673862145",
    "testharness"
   ],
   "payment-request/allowpaymentrequest/no-attribute-same-origin-bc-containers.https.html": [
    "ea3773ba7b6fc07d874d16355989833ffd2c66c7",
--- a/testing/web-platform/tests/payment-request/allowpaymentrequest/common.sub.js
+++ b/testing/web-platform/tests/payment-request/allowpaymentrequest/common.sub.js
@@ -1,45 +1,61 @@
 // Test should set these:
 // const expectSuccess = {'iframe': bool, 'frame': bool, 'object': bool, 'embed': bool};
 // const setAllowPaymentRequest = bool;
 // const testCrossOrigin = bool;
 
 const tests = {};
 
-window.onmessage = (e) => {
+window.onmessage = e => {
   const result = e.data;
   const tagName = result.urlQuery;
   const t = tests[tagName];
   t.step(() => {
     if (expectSuccess[tagName]) {
-      assert_equals(result.message, 'Success');
+      assert_equals(result.message, "Success");
+      if (result.message === "Exception") {
+        const [, code, name, stack] = result.details;
+        assert_unreached(`Unexpected exception "${name}" (${code}) ${stack}`);
+      }
     } else {
-      assert_equals(result.message, 'Exception');
-      assert_array_equals(result.details, [true /*ex instanceof DOMException*/,
-                                           DOMException.SECURITY_ERR /*ex.code*/,
-                                           'SecurityError' /*ex.name*/]);
+      assert_equals(result.message, "Exception");
+      const detailsArray = result.details.slice(0,3);
+      assert_array_equals(detailsArray, [
+        true /*ex instanceof DOMException*/,
+        DOMException.SECURITY_ERR /*ex.code*/,
+        "SecurityError" /*ex.name*/,
+      ]);
     }
     t.done();
   });
 };
 
-['iframe', 'frame', 'object', 'embed'].forEach((tagName, i) => {
-  tests[tagName] = async_test((t) => {
+["iframe", "frame", "object", "embed"].forEach((tagName, i) => {
+  tests[tagName] = async_test(t => {
     const elm = document.createElement(tagName);
     if (setAllowPaymentRequest) {
-      elm.setAttribute('allowpaymentrequest', '');
+      elm.setAttribute("allowpaymentrequest", "");
     }
-    const path = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
-    const url = (testCrossOrigin ? "https://{{domains[www1]}}:{{ports[https][0]}}" : "") +
-                path + "echo-PaymentRequest.html?" + tagName;
-    if (tagName === 'object') {
+    const path = location.pathname.substring(
+      0,
+      location.pathname.lastIndexOf("/") + 1
+    );
+    const url =
+      (testCrossOrigin ? "https://{{domains[www1]}}:{{ports[https][0]}}" : "") +
+      path +
+      "echo-PaymentRequest.html?" +
+      tagName;
+    if (tagName === "object") {
       elm.data = url;
     } else {
       elm.src = url;
     }
     elm.onload = t.step_func(() => {
-      window[i].postMessage('What is the result of new PaymentRequest(...)?', '*');
+      window[i].postMessage(
+        "What is the result of new PaymentRequest(...)?",
+        "*"
+      );
     });
-    elm.onerror = t.unreached_func('elm.onerror');
+    elm.onerror = t.unreached_func("elm.onerror");
     document.body.appendChild(elm);
   }, tagName);
 });
--- a/testing/web-platform/tests/payment-request/allowpaymentrequest/echo-PaymentRequest.html
+++ b/testing/web-platform/tests/payment-request/allowpaymentrequest/echo-PaymentRequest.html
@@ -6,17 +6,19 @@ window.onmessage = (e) => {
   if (e.data === 'What is the result of new PaymentRequest(...)?') {
     const result = {urlQuery: location.search.substring(1)}; // Used to distinguish subtests
     try {
       new PaymentRequest(...paymentArgs);
       result.message = 'Success';
       e.source.postMessage(result, '*');
     } catch(ex) {
       result.message = 'Exception';
-      result.details = [ex instanceof DOMException, ex.code, ex.name];
+      const isDomException = ex instanceof DOMException;
+      const stack = "stack" in ex ? ex.stack : "";
+      result.details = [ isDomException, ex.code, ex.name, stack ];
       e.source.postMessage(result, '*');
     }
   } else {
     result.message = 'Incorrect message';
     e.source.postMessage(result, '*');
   }
 }
 </script>