Title: [227398] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/LayoutTests/ChangeLog (227397 => 227398)


--- branches/safari-605-branch/LayoutTests/ChangeLog	2018-01-23 06:42:29 UTC (rev 227397)
+++ branches/safari-605-branch/LayoutTests/ChangeLog	2018-01-23 06:42:36 UTC (rev 227398)
@@ -1,5 +1,27 @@
 2018-01-22  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227277. rdar://problem/36763214
+
+    2018-01-21  Andy Estes  <aes...@apple.com>
+
+            [ios] LayoutTest imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html is crashing in JSC::JSONParse
+            https://bugs.webkit.org/show_bug.cgi?id=177832
+            <rdar://problem/34805315>
+
+            Reviewed by Tim Horton.
+
+            Made a copy of imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html
+            and modified it to handle Apple Pay and user gesture requirements.
+
+            * http/tests/paymentrequest/rejects_if_not_active.https-expected.txt: Added.
+            * http/tests/paymentrequest/rejects_if_not_active.https.html: Added.
+            * http/tests/paymentrequest/resources/page1.html: Added.
+            * http/tests/paymentrequest/resources/page2.html: Added.
+            * platform/ios-wk2/TestExpectations:
+            * platform/mac-wk2/TestExpectations:
+
+2018-01-22  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227338. rdar://problem/36746095
 
     2018-01-22  Andy Estes  <aes...@apple.com>

Added: branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https-expected.txt (0 => 227398)


--- branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https-expected.txt	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https-expected.txt	2018-01-23 06:42:36 UTC (rev 227398)
@@ -0,0 +1,5 @@
+
+PASS PaymentRequest.show() aborts if the document is not active 
+PASS PaymentRequest.show() aborts if the document is active, but not fully active 
+PASS If a payment request is showing, but its document is navigated away (so no longer fully active), the payment request aborts. 
+

Added: branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https.html (0 => 227398)


--- branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https.html	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/rejects_if_not_active.https.html	2018-01-23 06:42:36 UTC (rev 227398)
@@ -0,0 +1,178 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<link rel="help" href=""
+<title>PaymentRequest show() rejects if doc is not fully active</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<link rel="help" href=""
+<body>
+<script>
+const basicCardMethod = Object.freeze({
+  supportedMethods: "basic-card",
+});
+const applePayMethod = Object.freeze({
+  supportedMethods: "https://apple.com/apple-pay",
+  data: {
+    version: 2,
+    merchantIdentifier: '',
+    merchantCapabilities: ['supports3DS'],
+    supportedNetworks: ['visa', 'masterCard'],
+    countryCode: 'US',
+  },
+});
+const validMethods = Object.freeze([basicCardMethod, applePayMethod]);
+const validAmount = Object.freeze({
+  currency: "USD",
+  value: "5.00",
+});
+const validTotal = Object.freeze({
+  label: "Total due",
+  amount: validAmount,
+});
+const validDetails = Object.freeze({
+  total: validTotal,
+});
+
+function getLoadedPaymentRequest(iframe, url) {
+  return new Promise(resolve => {
+    iframe.addEventListener(
+      "load",
+      () => {
+        const { PaymentRequest } = iframe.contentWindow;
+        const request = new PaymentRequest(validMethods, validDetails);
+        resolve(request);
+      },
+      { once: true }
+    );
+    iframe.src = ""
+  });
+}
+
+promise_test(async t => {
+  // Check that PaymentRequests can be constructed.
+  new PaymentRequest(validMethods, validDetails);
+  const iframe = document.createElement("iframe");
+  iframe.allowPaymentRequest = true;
+  document.body.appendChild(iframe);
+
+  // We first got to page1.html, grab a PaymentRequest instance.
+  const request1 = await getLoadedPaymentRequest(
+    iframe,
+    "resources/page1.html"
+  );
+
+  // We navigate the iframe again, putting request1's document into an inactive state.
+  const request2 = await getLoadedPaymentRequest(
+    iframe,
+    "resources/page2.html"
+  );
+
+  // Now, request1's relevant global object's document is no longer active.
+  // So, call .show(), and make sure it rejects appropriately.
+  await promise_rejects(
+    t,
+    "AbortError",
+    request1.show(),
+    "Inactive document, so must throw AbortError"
+  );
+
+  // request2 has an active document tho, so confirm it's working as expected:
+  await activateThen(async () => {
+      request2.show().catch((error) => {});
+    await request2.abort();
+  });
+
+  await activateThen(async () => {
+    await promise_rejects(
+      t,
+      "InvalidStateError",
+      request2.show(),
+      "Abort already called, so InvalidStateError"
+    );
+  });
+
+  // We are done, so clean up.
+  iframe.remove();
+}, "PaymentRequest.show() aborts if the document is not active");
+
+promise_test(async t => {
+  // check that PaymentRequests can be constructed (smoke test).
+  new PaymentRequest(validMethods, validDetails);
+
+  // We nest two iframes and wait for them to load.
+  const outerIframe = document.createElement("iframe");
+  outerIframe.allowPaymentRequest = true;
+  document.body.appendChild(outerIframe);
+  // Load the outer iframe (we don't care about the awaited request)
+  await getLoadedPaymentRequest(
+    outerIframe,
+    "resources/page1.html"
+  );
+
+  // Now we create the inner iframe
+  const innerIframe = outerIframe.contentDocument.createElement("iframe");
+  innerIframe.allowPaymentRequest = true;
+
+  // nest them
+  outerIframe.contentDocument.body.appendChild(innerIframe);
+
+  // load innerIframe, and get the PaymentRequest instance
+  const request = await getLoadedPaymentRequest(
+    innerIframe,
+    "resources/page2.html"
+  );
+
+  // Navigate the outer iframe to a new location.
+  // Wait for the load event to fire.
+  await new Promise(resolve => {
+    outerIframe.addEventListener("load", resolve);
+    outerIframe.src = ""
+  });
+  // Now, request's relevant global object's document is still active
+  // (it is the active document of the inner iframe), but is not fully active
+  // (since the parent of the inner iframe is itself no longer active).
+  // So, call request.show() and make sure it rejects appropriately.
+  await promise_rejects(
+    t,
+    "AbortError",
+    request.show(),
+    "Active, but not fully active, so must throw AbortError"
+  );
+
+  // We are done, so clean up.
+  outerIframe.remove();
+}, "PaymentRequest.show() aborts if the document is active, but not fully active");
+
+promise_test(async t => {
+  // Check that PaymentRequests can be constructed.
+  new PaymentRequest(validMethods, validDetails);
+  const iframe = document.createElement("iframe");
+  iframe.allowPaymentRequest = true;
+  document.body.appendChild(iframe);
+  // Make a request in the iframe.
+  const request = await getLoadedPaymentRequest(
+    iframe,
+    "resources/page1.html"
+  );
+  // Present the payment sheet.
+  await activateThen(async () => {
+    const showPromise = request.show();
+    // Navigate the iframe to a new location. Wait for the load event to fire.
+    await new Promise(resolve => {
+      iframe.addEventListener("load", resolve);
+      iframe.src = ""
+    });
+    await promise_rejects(
+      t,
+      "AbortError",
+      showPromise,
+      "The iframe was navigated away, so showPromise must reject with AbortError"
+    );
+  });
+
+  // We are done, so clean up.
+  iframe.remove();
+}, "If a payment request is showing, but its document is navigated away (so no longer fully active), the payment request aborts.");
+</script>

Added: branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page1.html (0 => 227398)


--- branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page1.html	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page1.html	2018-01-23 06:42:36 UTC (rev 227398)
@@ -0,0 +1 @@
+<meta charset="utf-8">

Added: branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page2.html (0 => 227398)


--- branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page2.html	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/paymentrequest/resources/page2.html	2018-01-23 06:42:36 UTC (rev 227398)
@@ -0,0 +1 @@
+<meta charset="utf-8">

Modified: branches/safari-605-branch/LayoutTests/platform/ios-wk2/TestExpectations (227397 => 227398)


--- branches/safari-605-branch/LayoutTests/platform/ios-wk2/TestExpectations	2018-01-23 06:42:29 UTC (rev 227397)
+++ branches/safari-605-branch/LayoutTests/platform/ios-wk2/TestExpectations	2018-01-23 06:42:36 UTC (rev 227398)
@@ -42,6 +42,7 @@
 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ]
 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ]
 imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html [ WontFix ]
+imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ WontFix ]
 
  # skip manual payment-request tests
 imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ]
@@ -1280,8 +1281,6 @@
 
 webkit.org/b/176240 http/tests/websocket/tests/hybi/handshake-ok-with-legacy-websocket-response-headers.html [ Pass Failure ]
 
-webkit.org/b/177832 imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ Skip ]
-
 webkit.org/b/173608 webrtc/video-replace-muted-track.html [ Skip ]
 
 webkit.org/b/177501 webrtc/video-mute.html [ Pass Timeout ]

Modified: branches/safari-605-branch/LayoutTests/platform/mac-wk2/TestExpectations (227397 => 227398)


--- branches/safari-605-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-01-23 06:42:29 UTC (rev 227397)
+++ branches/safari-605-branch/LayoutTests/platform/mac-wk2/TestExpectations	2018-01-23 06:42:36 UTC (rev 227398)
@@ -35,12 +35,12 @@
 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html [ Skip ]
 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html [ Skip ]
 webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html [ Skip ]
-webkit.org/b/177783 imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ Skip ]
 
 # skip in favor of tests in http/tests/paymentrequest
 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ]
 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ]
 imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https.html [ WontFix ]
+imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ WontFix ]
 
 # skip manual payment-request tests
 imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ]

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (227397 => 227398)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-23 06:42:29 UTC (rev 227397)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-23 06:42:36 UTC (rev 227398)
@@ -1,5 +1,22 @@
 2018-01-22  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227277. rdar://problem/36763214
+
+    2018-01-21  Andy Estes  <aes...@apple.com>
+
+            [ios] LayoutTest imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html is crashing in JSC::JSONParse
+            https://bugs.webkit.org/show_bug.cgi?id=177832
+            <rdar://problem/34805315>
+
+            Reviewed by Tim Horton.
+
+            Test: http/tests/paymentrequest/rejects_if_not_active.https.html
+
+            * Modules/paymentrequest/PaymentRequest.cpp:
+            (WebCore::PaymentRequest::show): Rejected promise if the document is not active.
+
+2018-01-22  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227340. rdar://problem/36746140
 
     2018-01-22  Brady Eidson  <beid...@apple.com>

Modified: branches/safari-605-branch/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (227397 => 227398)


--- branches/safari-605-branch/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-01-23 06:42:29 UTC (rev 227397)
+++ branches/safari-605-branch/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-01-23 06:42:36 UTC (rev 227398)
@@ -382,6 +382,11 @@
 // https://www.w3.org/TR/payment-request/#show()-method
 void PaymentRequest::show(Document& document, ShowPromise&& promise)
 {
+    if (!document.frame()) {
+        promise.reject(Exception { AbortError });
+        return;
+    }
+
     if (!UserGestureIndicator::processingUserGesture()) {
         promise.reject(Exception { SecurityError, "show() must be triggered by user activation." });
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to