Title: [264553] trunk/LayoutTests/imported/w3c
Revision
264553
Author
[email protected]
Date
2020-07-17 16:33:53 -0700 (Fri, 17 Jul 2020)

Log Message

Resync web-platform-tests/credential-management from upstream
https://bugs.webkit.org/show_bug.cgi?id=214501

Reviewed by Geoffrey Garen.

Resync web-platform-tests/credential-management from upstream 81de986322a0de90f.

* resources/resource-files.json:
* web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt:
* web-platform-tests/credential-management/credentialscontainer-create-basics.https.html:
* web-platform-tests/credential-management/federatedcredential-framed-get.sub.https-expected.txt:
* web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html:
* web-platform-tests/credential-management/idlharness.https.window.js:
* web-platform-tests/credential-management/otpcredential-get-basics.https-expected.txt: Added.
* web-platform-tests/credential-management/otpcredential-get-basics.https.html: Added.
* web-platform-tests/credential-management/otpcredential-iframe.https-expected.txt: Added.
* web-platform-tests/credential-management/otpcredential-iframe.https.html: Added.
* web-platform-tests/credential-management/passwordcredential-framed-get.sub.https-expected.txt:
* web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html:
* web-platform-tests/credential-management/support/README.md: Added.
* web-platform-tests/credential-management/support/otpcredential-helper.js: Added.
(async loadChromiumResources):
(async create_sms_provider):
(receive):
(expect.return.async andReturn):
(expect):
* web-platform-tests/credential-management/support/otpcredential-iframe.html: Added.
* web-platform-tests/credential-management/support/w3c-import.log:
* web-platform-tests/credential-management/w3c-import.log:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-17 23:33:53 UTC (rev 264553)
@@ -1,5 +1,37 @@
 2020-07-17  Chris Dumez  <[email protected]>
 
+        Resync web-platform-tests/credential-management from upstream
+        https://bugs.webkit.org/show_bug.cgi?id=214501
+
+        Reviewed by Geoffrey Garen.
+
+        Resync web-platform-tests/credential-management from upstream 81de986322a0de90f.
+
+        * resources/resource-files.json:
+        * web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt:
+        * web-platform-tests/credential-management/credentialscontainer-create-basics.https.html:
+        * web-platform-tests/credential-management/federatedcredential-framed-get.sub.https-expected.txt:
+        * web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html:
+        * web-platform-tests/credential-management/idlharness.https.window.js:
+        * web-platform-tests/credential-management/otpcredential-get-basics.https-expected.txt: Added.
+        * web-platform-tests/credential-management/otpcredential-get-basics.https.html: Added.
+        * web-platform-tests/credential-management/otpcredential-iframe.https-expected.txt: Added.
+        * web-platform-tests/credential-management/otpcredential-iframe.https.html: Added.
+        * web-platform-tests/credential-management/passwordcredential-framed-get.sub.https-expected.txt:
+        * web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html:
+        * web-platform-tests/credential-management/support/README.md: Added.
+        * web-platform-tests/credential-management/support/otpcredential-helper.js: Added.
+        (async loadChromiumResources):
+        (async create_sms_provider):
+        (receive):
+        (expect.return.async andReturn):
+        (expect):
+        * web-platform-tests/credential-management/support/otpcredential-iframe.html: Added.
+        * web-platform-tests/credential-management/support/w3c-import.log:
+        * web-platform-tests/credential-management/w3c-import.log:
+
+2020-07-17  Chris Dumez  <[email protected]>
+
         Resync web-platform-tests/clipboard-apis from upstream
         https://bugs.webkit.org/show_bug.cgi?id=214496
 

Modified: trunk/LayoutTests/imported/w3c/resources/resource-files.json (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/resources/resource-files.json	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/resources/resource-files.json	2020-07-17 23:33:53 UTC (rev 264553)
@@ -94,6 +94,7 @@
         "web-platform-tests/content-security-policy/unsafe-hashes/support/child_window_location_navigate.sub.html",
         "web-platform-tests/credential-management/support/echoing-nester.html",
         "web-platform-tests/credential-management/support/federatedcredential-get.html",
+        "web-platform-tests/credential-management/support/otpcredential-iframe.html",
         "web-platform-tests/credential-management/support/passwordcredential-get.html",
         "web-platform-tests/css/WOFF2/available-001.xht",
         "web-platform-tests/css/WOFF2/available-002.xht",

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt	2020-07-17 23:33:53 UTC (rev 264553)
@@ -3,12 +3,18 @@
 PASS navigator.credentials.create() with empty argument. 
 FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
 FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
-FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus password data promise_rejects_js: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected instance of function "function TypeError() {
+    [native code]
+}" ("TypeError")
 FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
-FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus federated data promise_rejects_js: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected instance of function "function TypeError() {
+    [native code]
+}" ("TypeError")
 PASS navigator.credentials.create() with bogus publicKey data 
 PASS navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData 
-FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+FAIL navigator.credentials.create() with bogus password and federated data promise_rejects_js: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected instance of function "function TypeError() {
+    [native code]
+}" ("TypeError")
 PASS navigator.credentials.create() with bogus federated and publicKey data 
 PASS navigator.credentials.create() with bogus password and publicKey data 
 PASS navigator.credentials.create() with bogus password, federated, and publicKey data 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https.html (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https.html	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -4,12 +4,12 @@
 <script src=""
 <script>
 promise_test(function(t) {
-    return promise_rejects(t, "NotSupportedError",
+    return promise_rejects_dom(t, "NotSupportedError",
             navigator.credentials.create());
 }, "navigator.credentials.create() with no argument.");
 
 promise_test(function(t) {
-    return promise_rejects(t, "NotSupportedError",
+    return promise_rejects_dom(t, "NotSupportedError",
             navigator.credentials.create({}));
 }, "navigator.credentials.create() with empty argument.");
 
@@ -48,7 +48,7 @@
 }, "navigator.credentials.create() with valid HTMLFormElement");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({password: "bogus password data"}));
 }, "navigator.credentials.create() with bogus password data");
 
@@ -68,12 +68,12 @@
 }, "navigator.credentials.create() with valid FederatedCredentialData");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({federated: "bogus federated data"}));
 }, "navigator.credentials.create() with bogus federated data");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({publicKey: "bogus publicKey data"}));
 }, "navigator.credentials.create() with bogus publicKey data");
 
@@ -88,7 +88,7 @@
         provider: 'https://example.com/',
     };
 
-    return promise_rejects(t, "NotSupportedError",
+    return promise_rejects_dom(t, "NotSupportedError",
             navigator.credentials.create({
                 password: credential_data,
                 federated: federated_data,
@@ -96,7 +96,7 @@
 }, "navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({
                 password: "bogus password data",
                 federated: "bogus federated data",
@@ -104,7 +104,7 @@
 }, "navigator.credentials.create() with bogus password and federated data");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({
                 federated: "bogus federated data",
                 publicKey: "bogus publicKey data",
@@ -112,7 +112,7 @@
 }, "navigator.credentials.create() with bogus federated and publicKey data");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({
                 password: "bogus password data",
                 publicKey: "bogus publicKey data",
@@ -120,7 +120,7 @@
 }, "navigator.credentials.create() with bogus password and publicKey data");
 
 promise_test(function(t) {
-    return promise_rejects(t, new TypeError(),
+    return promise_rejects_js(t, TypeError,
             navigator.credentials.create({
                 password: "bogus password data",
                 federated: "bogus federated data",
@@ -129,7 +129,7 @@
 }, "navigator.credentials.create() with bogus password, federated, and publicKey data");
 
 promise_test(function(t) {
-    return promise_rejects(t, "NotSupportedError",
+    return promise_rejects_dom(t, "NotSupportedError",
             navigator.credentials.create({bogus_key: "bogus data"}));
 }, "navigator.credentials.create() with bogus data");
 </script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https-expected.txt (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https-expected.txt	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https-expected.txt	2020-07-17 23:33:53 UTC (rev 264553)
@@ -1,15 +1,5 @@
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/federatedcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/echoing-nester.html?origin=https://localhost:9443&file=federatedcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/echoing-nester.html?origin=https://xn--lve-6lad.localhost:9443&file=federatedcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/federatedcredential-get.html
+CONSOLE MESSAGE: Error: assert_implements: `FederatedCredential` is supported. undefined
 
+Harness Error (FAIL), message = Error: assert_implements: `FederatedCredential` is supported. undefined
 
-Harness Error (TIMEOUT), message = null
 
-FAIL Same-origin IFrame does not throw. assert_equals: expected "resolved" but got "rejected"
-TIMEOUT Cross-origin IFrame throws 'NotAllowedError'. Test timed out
-FAIL Same-origin IFrame in same-origin IFrame does not throw. assert_equals: expected "resolved" but got "rejected"
-TIMEOUT Same-origin IFrame in same-origin IFrame throws 'NotAllowedError'. Test timed out
-TIMEOUT Cross-origin IFrame in same-origin IFrame throws 'NotAllowedError'. Test timed out
-TIMEOUT Cross-origin IFrame in same-cross-origin throws 'NotAllowedError'. Test timed out
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -2,19 +2,23 @@
 <script src=""
 <script src=""
 <script>
+assert_implements('FederatedCredential' in window, "`FederatedCredential` is supported.");
+
+// Ensure that the check is "same origin", not "same origin-domain".
+document.domain = window.location.hostname;
+
 function create_iframe_test(origin, expectation) {
     return function (t) {
-        assert_true(!!navigator.credentials, "`navigator.credentials` is supported.");
         window.addEventListener("load", _ => {
             var iframe = document.createElement("iframe");
             iframe.src = "" + "/credential-management/support/federatedcredential-get.html";
             window.addEventListener("message", t.step_func(e => {
                 if (e.source == iframe.contentWindow) {
-                    assert_equals(e.data.status, expectation);
-                    if (expectation == "rejected") {
+                    if (expectation == "blocked") {
                       assert_equals(e.data.exception, "NotAllowedError");
                     } else {
-                      assert_equals(e.data.exception, null);
+                      if (e.data.exception)
+                        assert_not_equals(e.data.exception, "NotAllowedError");
                     }
                     t.done();
                 }
@@ -26,14 +30,12 @@
 
 function create_nested_iframe_test(outerOrigin, innerOrigin, expectation) {
     return function (t) {
-        assert_true(!!navigator.credentials, "`navigator.credentials` is supported.");
         window.addEventListener("load", _ => {
             var iframe = document.createElement("iframe");
             iframe.src = "" + "/credential-management/support/echoing-nester.html?origin=" + innerOrigin + "&file=federatedcredential-get.html";
             window.addEventListener("message", t.step_func(e => {
                 if (e.source == iframe.contentWindow) {
-                    assert_equals(e.data.status, expectation);
-                    if (expectation == "rejected") {
+                    if (expectation == "blocked") {
                       assert_equals(e.data.exception, "NotAllowedError");
                     } else {
                       assert_equals(e.data.exception, null);
@@ -50,25 +52,25 @@
 const CROSS_ORIGIN = "https://{{domains[élève]}}:{{ports[https][0]}}";
 
 async_test(
-    create_iframe_test(SAME_ORIGIN, "resolved"),
+    create_iframe_test(SAME_ORIGIN, "allowed"),
     "Same-origin IFrame does not throw.");
 async_test(
-    create_iframe_test(CROSS_ORIGIN, "rejected"),
+    create_iframe_test(CROSS_ORIGIN, "blocked"),
     "Cross-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(SAME_ORIGIN, SAME_ORIGIN, "resolved"),
+    create_nested_iframe_test(SAME_ORIGIN, SAME_ORIGIN, "allowed"),
     "Same-origin IFrame in same-origin IFrame does not throw.");
 
 async_test(
-    create_nested_iframe_test(SAME_ORIGIN, CROSS_ORIGIN, "rejected"),
+    create_nested_iframe_test(SAME_ORIGIN, CROSS_ORIGIN, "blocked"),
     "Same-origin IFrame in same-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(CROSS_ORIGIN, SAME_ORIGIN, "rejected"),
+    create_nested_iframe_test(CROSS_ORIGIN, SAME_ORIGIN, "blocked"),
     "Cross-origin IFrame in same-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(CROSS_ORIGIN, CROSS_ORIGIN, "rejected"),
+    create_nested_iframe_test(CROSS_ORIGIN, CROSS_ORIGIN, "blocked"),
     "Cross-origin IFrame in same-cross-origin throws 'NotAllowedError'.");
 </script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/idlharness.https.window.js (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/idlharness.https.window.js	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/idlharness.https.window.js	2020-07-17 23:33:53 UTC (rev 264553)
@@ -1,5 +1,6 @@
 // META: script=/resources/WebIDLParser.js
 // META: script=/resources/idlharness.js
+// META: timeout=long
 
 // https://w3c.github.io/webappsec-credential-management/
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https-expected.txt (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https-expected.txt	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,7 @@
+
+FAIL Basic usage promise_test: Unhandled rejection with value: object "Error: Mojo testing interface is not available."
+FAIL Handle multiple requests in different order. promise_test: Unhandled rejection with value: object "Error: Mojo testing interface is not available."
+FAIL Handle multiple requests with success and error. promise_test: Unhandled rejection with value: object "Error: Mojo testing interface is not available."
+FAIL Deal with cancelled requests promise_test: Unhandled rejection with value: object "Error: Mojo testing interface is not available."
+PASS Should abort request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https.html (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<link rel="help" href=""
+<title>Tests OTPCredential</title>
+<script src=""
+<script src=""
+<script src=""
+<script>
+'use strict';
+
+promise_test(async t => {
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kSuccess, otp: "ABC"};
+  });
+
+  let cred = await navigator.credentials.get({otp: {transport: ["sms"]}});
+
+  assert_equals(cred.code, "ABC");
+}, 'Basic usage');
+
+promise_test(async t => {
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kSuccess, otp: "ABC"};
+  });
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kSuccess, otp: "ABC2"};
+  });
+
+  let sms1 = navigator.credentials.get({otp: {transport: ["sms"]}});
+  let sms2 = navigator.credentials.get({otp: {transport: ["sms"]}});
+
+  let cred2= await sms2;
+  let cred1 = await sms1;
+
+  assert_equals(cred1.code, "ABC");
+  assert_equals(cred2.code, "ABC2");
+}, 'Handle multiple requests in different order.');
+
+promise_test(async t => {
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kCancelled};
+  });
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kSuccess, otp: "success"};
+  });
+
+  let cancelled_sms = navigator.credentials.get({otp: {transport: ["sms"]}});
+  let successful_sms = navigator.credentials.get({otp: {transport: ["sms"]}});
+
+  let successful_cred = await successful_sms;
+  assert_equals(successful_cred.code, "success");
+
+  try {
+    await cancelled_sms;
+    assert_unreached('Expected AbortError to be thrown.');
+  } catch (error) {
+    assert_equals(error.name, "AbortError");
+  }
+}, 'Handle multiple requests with success and error.');
+
+promise_test(async t => {
+  await expect(receive).andReturn(async () => {
+      return {status: Status.kCancelled};
+  });
+
+  await promise_rejects_dom(t, 'AbortError', navigator.credentials.get(
+    {otp: {transport: ["sms"]}}));
+}, 'Deal with cancelled requests');
+
+promise_test(async t => {
+  const controller = new AbortController();
+  const signal = controller.signal;
+
+  controller.abort();
+  await promise_rejects_dom(t, 'AbortError', navigator.credentials.get(
+    {otp: {transport: ["sms"]}, signal: signal}));
+}, 'Should abort request');
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https-expected.txt (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https-expected.txt	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Mojo testing interface is not available.
+CONSOLE MESSAGE: Unhandled Promise Rejection: Error: Mojo testing interface is not available.
+
+FAIL Test OTPCredential enabled in same origin iframes assert_equals: expected "Pass" but got "Fail"
+FAIL Test OTPCredential disabled in cross origin iframes assert_equals: expected "NotAllowedError" but got "NotSupportedError"
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https.html (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,41 @@
+<!doctype html>
+<script src=""
+<script src=""
+<script src=""
+<div id=log>
+<script>
+'use strict';
+
+const host = get_host_info();
+const remoteBaseURL =
+    host.HTTPS_REMOTE_ORIGIN +
+    window.location.pathname.replace(/\/[^\/]*$/, '/');
+const localBaseURL =
+    host.HTTPS_ORIGIN +
+    window.location.pathname.replace(/\/[^\/]*$/, '/');
+
+promise_test(async t => {
+  const messageWatcher = new EventWatcher(t, window, "message");
+  var iframe = document.createElement("iframe");
+  iframe.src = "" + "support/otpcredential-iframe.html";
+
+  document.body.appendChild(iframe);
+
+  const message = await messageWatcher.wait_for("message");
+  assert_equals(message.data.result, "Pass");
+  assert_equals(message.data.code, "ABC123");
+
+}, "Test OTPCredential enabled in same origin iframes");
+
+promise_test(async t => {
+  const messageWatcher = new EventWatcher(t, window, "message");
+  var iframe = document.createElement("iframe");
+  iframe.src = "" + "support/otpcredential-iframe.html"
+  document.body.appendChild(iframe);
+
+  const message = await messageWatcher.wait_for("message");
+  assert_equals(message.data.result, "Fail");
+  assert_equals(message.data.errorType, "NotAllowedError");
+
+}, "Test OTPCredential disabled in cross origin iframes");
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https-expected.txt (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https-expected.txt	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https-expected.txt	2020-07-17 23:33:53 UTC (rev 264553)
@@ -1,15 +1,5 @@
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/passwordcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/echoing-nester.html?origin=https://localhost:9443&file=passwordcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/echoing-nester.html?origin=https://xn--lve-6lad.localhost:9443&file=passwordcredential-get.html
-Blocked access to external URL https://xn--lve-6lad.localhost:9443/credential-management/support/passwordcredential-get.html
+CONSOLE MESSAGE: Error: assert_implements: `PasswordCredential` is supported. undefined
 
+Harness Error (FAIL), message = Error: assert_implements: `PasswordCredential` is supported. undefined
 
-Harness Error (TIMEOUT), message = null
 
-FAIL Same-origin IFrame does not throw. assert_equals: expected "resolved" but got "rejected"
-TIMEOUT Cross-origin IFrame throws 'NotAllowedError'. Test timed out
-FAIL Same-origin IFrame in same-origin IFrame does not throw. assert_equals: expected "resolved" but got "rejected"
-TIMEOUT Same-origin IFrame in same-origin IFrame throws. Test timed out
-TIMEOUT Cross-origin IFrame in same-origin IFrame throws. Test timed out
-TIMEOUT Cross-origin IFrame in same-cross-origin throws. Test timed out
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -2,19 +2,23 @@
 <script src=""
 <script src=""
 <script>
+assert_implements('PasswordCredential' in window, "`PasswordCredential` is supported.");
+
+// Ensure that the check is "same origin", not "same origin-domain".
+document.domain = window.location.hostname;
+
 function create_iframe_test(origin, expectation) {
     return function (t) {
-        assert_true(!!navigator.credentials, "`navigator.credentials` is supported.");
         window.addEventListener("load", _ => {
             var iframe = document.createElement("iframe");
             iframe.src = "" + "/credential-management/support/passwordcredential-get.html";
             window.addEventListener("message", t.step_func(e => {
                 if (e.source == iframe.contentWindow) {
-                    assert_equals(e.data.status, expectation);
-                    if (expectation == "rejected") {
+                    if (expectation == "blocked") {
                       assert_equals(e.data.exception, "NotAllowedError");
                     } else {
-                      assert_equals(e.data.exception, null);
+                      if (e.data.exception)
+                        assert_not_equals(e.data.exception, "NotAllowedError");
                     }
                     t.done();
                 }
@@ -26,14 +30,12 @@
 
 function create_nested_iframe_test(outerOrigin, innerOrigin, expectation) {
     return function (t) {
-        assert_true(!!navigator.credentials, "`navigator.credentials` is supported.");
         window.addEventListener("load", _ => {
             var iframe = document.createElement("iframe");
             iframe.src = "" + "/credential-management/support/echoing-nester.html?origin=" + innerOrigin + "&file=passwordcredential-get.html";
             window.addEventListener("message", t.step_func(e => {
                 if (e.source == iframe.contentWindow) {
-                    assert_equals(e.data.status, expectation);
-                    if (expectation == "rejected") {
+                    if (expectation == "blocked") {
                       assert_equals(e.data.exception, "NotAllowedError");
                     } else {
                       assert_equals(e.data.exception, null);
@@ -50,25 +52,25 @@
 const CROSS_ORIGIN = "https://{{domains[élève]}}:{{ports[https][0]}}";
 
 async_test(
-    create_iframe_test(SAME_ORIGIN, "resolved"),
+    create_iframe_test(SAME_ORIGIN, "allowed"),
     "Same-origin IFrame does not throw.");
 async_test(
-    create_iframe_test(CROSS_ORIGIN, "rejected"),
+    create_iframe_test(CROSS_ORIGIN, "blocked"),
     "Cross-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(SAME_ORIGIN, SAME_ORIGIN, "resolved"),
+    create_nested_iframe_test(SAME_ORIGIN, SAME_ORIGIN, "allowed"),
     "Same-origin IFrame in same-origin IFrame does not throw.");
 
 async_test(
-    create_nested_iframe_test(SAME_ORIGIN, CROSS_ORIGIN, "rejected"),
-    "Same-origin IFrame in same-origin IFrame throws.");
+    create_nested_iframe_test(SAME_ORIGIN, CROSS_ORIGIN, "blocked"),
+    "Same-origin IFrame in same-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(CROSS_ORIGIN, SAME_ORIGIN, "rejected"),
-    "Cross-origin IFrame in same-origin IFrame throws.");
+    create_nested_iframe_test(CROSS_ORIGIN, SAME_ORIGIN, "blocked"),
+    "Cross-origin IFrame in same-origin IFrame throws 'NotAllowedError'.");
 
 async_test(
-    create_nested_iframe_test(CROSS_ORIGIN, CROSS_ORIGIN, "rejected"),
-    "Cross-origin IFrame in same-cross-origin throws.");
+    create_nested_iframe_test(CROSS_ORIGIN, CROSS_ORIGIN, "blocked"),
+    "Cross-origin IFrame in same-cross-origin throws 'NotAllowedError'.");
 </script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/README.md (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/README.md	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/README.md	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,30 @@
+# CredentialManagement Testing
+
+## OTPCredential Testing
+
+In this test suite `otpcredential-helper.js` is a testing framework that enables
+engines to test OTPCredential by intercepting the connection between the browser
+and the underlying operating system and mock its behavior.
+
+Usage:
+
+1. Include `<script src="" in your
+test
+2. Set expectations
+```
+await expect(receive).andReturn(() => {
+  // mock behavior
+})
+```
+3. Call `navigator.credentials.get({otp: {transport: ["sms"]}})`
+4. Verify results
+
+The mocking API is browser agnostic and is designed such that other engines
+could implement it too.
+
+Here are the symbols that are exposed to tests that need to be implemented
+per engine:
+
+- function receive(): the main/only function that can be mocked
+- function expect(): the main/only function that enables us to mock it
+- enum State {kSuccess, kTimeout}: allows you to mock success/failures

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-helper.js (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-helper.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-helper.js	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,65 @@
+'use strict';
+
+// These tests rely on the User Agent providing an implementation of
+// the sms retriever.
+//
+// In Chromium-based browsers this implementation is provided by a polyfill
+// in order to reduce the amount of test-only code shipped to users. To enable
+// these tests the browser must be run with these options:
+// //   --enable-blink-features=MojoJS,MojoJSTest
+
+async function loadChromiumResources() {
+  if (!window.MojoInterfaceInterceptor) {
+    // Do nothing on non-Chromium-based browsers or when the Mojo bindings are
+    // not present in the global namespace.
+    return;
+  }
+
+  const resources = [
+    '/gen/layout_test_data/mojo/public/js/mojo_bindings_lite.js',
+    '/gen/mojo/public/mojom/base/time.mojom-lite.js',
+    '/gen/third_party/blink/public/mojom/sms/sms_receiver.mojom-lite.js',
+    '/resources/chromium/mock-sms-receiver.js',
+  ];
+
+  await Promise.all(resources.map(path => {
+    const script = document.createElement('script');
+    script.src = ""
+    script.async = false;
+    const promise = new Promise((resolve, reject) => {
+      script._onload_ = resolve;
+      script._onerror_ = reject;
+    });
+    document.head.appendChild(script);
+    return promise;
+  }));
+
+  Status.kSuccess = blink.mojom.SmsStatus.kSuccess;
+  Status.kTimeout = blink.mojom.SmsStatus.kTimeout;
+  Status.kCancelled = blink.mojom.SmsStatus.kCancelled;
+};
+
+const Status = {};
+
+async function create_sms_provider() {
+  if (typeof SmsProvider === 'undefined') {
+    await loadChromiumResources();
+  }
+  if (typeof SmsProvider == 'undefined') {
+    throw new Error('Mojo testing interface is not available.');
+  }
+  return new SmsProvider();
+}
+
+function receive() {
+  throw new Error("expected to be overriden by tests");
+}
+
+function expect(call) {
+  return {
+    async andReturn(callback) {
+      const mock = await create_sms_provider();
+      mock.pushReturnValuesForTesting(call.name, callback);
+    }
+  }
+}

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-iframe.html (0 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-iframe.html	2020-07-17 23:33:53 UTC (rev 264553)
@@ -0,0 +1,35 @@
+<!doctype html>
+<script src=""
+<script>
+'use strict';
+
+// Loading otpcredential-iframe.html in the test will make an OTPCredentials
+// call on load, and trigger a postMessage upon completion.
+//
+// message {
+//   string result: "Pass" | "Fail"
+//   string code: credentials.code
+//   string errorType: error.name
+// }
+
+// Intercept successful calls and return mocked value.
+(async function() {
+    await expect(receive).andReturn(() => {
+        return Promise.resolve({
+            status: Status.kSuccess,
+            otp: "ABC123",
+        });
+    });
+}());
+
+window._onload_ = async () => {
+    try {
+        const credentials =
+            await navigator.credentials.get({otp: {transport: ["sms"]}});
+        window.parent.postMessage({result: "Pass", code: credentials.code}, '*');
+    } catch (error) {
+        window.parent.postMessage({result: "Fail", errorType: error.name}, '*');
+    }
+}
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/w3c-import.log (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/w3c-import.log	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/w3c-import.log	2020-07-17 23:33:53 UTC (rev 264553)
@@ -14,6 +14,9 @@
 None
 ------------------------------------------------------------------------
 List of files:
+/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/README.md
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/support/echoing-nester.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/support/federatedcredential-get.html
+/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-helper.js
+/LayoutTests/imported/w3c/web-platform-tests/credential-management/support/otpcredential-iframe.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/support/passwordcredential-get.html

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/w3c-import.log (264552 => 264553)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/w3c-import.log	2020-07-17 23:32:04 UTC (rev 264552)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/w3c-import.log	2020-07-17 23:33:53 UTC (rev 264553)
@@ -18,5 +18,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/federatedcredential-framed-get.sub.https.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/idlharness.https.window.js
+/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-get-basics.https.html
+/LayoutTests/imported/w3c/web-platform-tests/credential-management/otpcredential-iframe.https.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/passwordcredential-framed-get.sub.https.html
 /LayoutTests/imported/w3c/web-platform-tests/credential-management/require_securecontext.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to