Skip to content

Commit

Permalink
[fenced-frames] Migrate WebAuthn test
Browse files Browse the repository at this point in the history
Migrate a fenced frames WebAuthn test to run on headless chrome with
chromedriver instead of the legacy content shell runner. The legacy
content shell runner will stop supporting the WebAuthn testdriver API,
soon.

Fix the test to set up the virtual authenticator environment on the top
frame instead, since testdriver should be invoked from the same window
hosting the testharness.

Bug: 372169469
Change-Id: I6e1b296fe86ee4087da2a5a63868e18a6b440984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5920770
Auto-Submit: Nina Satragno <nsatragno@chromium.org>
Reviewed-by: Liam Brady <lbrady@google.com>
Commit-Queue: Liam Brady <lbrady@google.com>
Cr-Commit-Position: refs/heads/main@{#1367535}
  • Loading branch information
nsatragno authored and chromium-wpt-export-bot committed Oct 12, 2024
1 parent 280d04e commit 5611c15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
27 changes: 16 additions & 11 deletions fenced-frame/create-credential.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/webauthn/helpers.js"></script>
<script src="/common/utils.js"></script>
<script src="resources/utils.js"></script>

<body>

<script>
promise_test(async () => {
const key = token();
attachFencedFrame(
generateURL('resources/create-credential-inner.https.html', [key]));
// Get the result for the fenced frame.
const fenced_frame_result = await nextValueFromServer(key);
assert_equals(
fenced_frame_result,
'createCredential failed',
'credentials.create should fail on fenced frame');
}, 'navigator.credentials.create');
standardSetup(function () {
promise_test(async () => {
const key = token();
attachFencedFrame(
generateURL('resources/create-credential-inner.https.html', [key]));
// Get the result for the fenced frame.
const fenced_frame_result = await nextValueFromServer(key);
assert_equals(
fenced_frame_result,
'createCredential failed',
'credentials.create should fail on fenced frame');
}, 'navigator.credentials.create');
});
</script>

</body>
36 changes: 13 additions & 23 deletions fenced-frame/resources/create-credential-inner.https.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/webauthn/helpers.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="utils.js"></script>
<title>Fenced frame content to report the result of navigator.credentials.create</title>
Expand All @@ -13,26 +10,19 @@
return location.pathname.replace(/\/[^\/]*$/, '/');
}

standardSetup(function() {
'use strict';
async function init() {
// This file is meant to be navigated to from a <fencedframe> element. It
// reports back to the page hosting the <fencedframe> whether or not
// `navigator.credentials.create` is allowed.
const [key] = parseKeylist();
// This file is meant to be navigated to from a <fencedframe> element. It
// reports back to the page hosting the <fencedframe> whether or not
// `navigator.credentials.create` is allowed.
const [key] = parseKeylist();

// Report whether or not `credentials.create` is allowed.
createCredential().then(
() => {
writeValueToServer(key, 'createCredential passed');
},
() => {
writeValueToServer(key, 'createCredential failed');
},
);
}

init();
});
// Report whether or not `credentials.create` is allowed.
createCredential().then(
() => {
writeValueToServer(key, 'createCredential passed');
},
() => {
writeValueToServer(key, 'createCredential failed');
},
);
</script>
</body>

0 comments on commit 5611c15

Please sign in to comment.