-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Digital Credentials: Add WebDriver automation commands and tests #58587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mohamedamir
wants to merge
4
commits into
web-platform-tests:master
Choose a base branch
from
mohamedamir:digital-credentials-webdriver-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0d6819b
Digital Credentials: Add WebDriver automation and tests
mohamedamir b24d723
Apply suggestions from Marcos
mohamedamir 3db210a
Merge branch 'web-platform-tests:master' into digital-credentials-web…
mohamedamir ba5b87a
Merge branch 'web-platform-tests:master' into digital-credentials-web…
mohamedamir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <!DOCTYPE html> | ||
| <title>Digital Credential API: create() webdriver tests.</title> | ||
| <link rel="help" href="https://wicg.github.io/digital-credentials/"> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/resources/testdriver.js?feature=bidi"></script> | ||
| <script src="/resources/testdriver-vendor.js"></script> | ||
| <body></body> | ||
| <script type="module"> | ||
| import { makeCreateOptions } from "../support/helper.js"; | ||
|
|
||
| promise_test(async (t) => { | ||
| const responseData = "test-create-response-data"; | ||
| await test_driver.set_virtual_wallet_behavior("respond", "openid4vci", { "value": responseData }); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeCreateOptions({ protocol: "openid4vci" }); | ||
| const result = await navigator.credentials.create(options); | ||
|
|
||
| assert_equals(result.protocol, "openid4vci"); | ||
| assert_equals(result.data.value, responseData); | ||
| }, "navigator.credentials.create() with respond mode should resolve with the specified data."); | ||
|
|
||
| promise_test(async (t) => { | ||
| const complexData = { "a": 1, "b": [2, 3], "c": { "d": 4 } }; | ||
| await test_driver.set_virtual_wallet_behavior("respond", "openid4vci", complexData); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeCreateOptions({ protocol: "openid4vci" }); | ||
| const result = await navigator.credentials.create(options); | ||
|
|
||
| assert_equals(result.protocol, "openid4vci"); | ||
| assert_equals(result.data.a, 1); | ||
| assert_array_equals(result.data.b, [2, 3]); | ||
| assert_equals(result.data.c.d, 4); | ||
| }, "navigator.credentials.create() with complex data response should resolve with structured data."); | ||
|
|
||
| promise_test(async (t) => { | ||
| await test_driver.set_virtual_wallet_behavior("decline"); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeCreateOptions({ protocol: "openid4vci" }); | ||
| await promise_rejects_dom(t, "NotAllowedError", navigator.credentials.create(options)); | ||
| }, "navigator.credentials.create() with decline mode should reject with NotAllowedError."); | ||
|
|
||
| promise_test(async (t) => { | ||
| await test_driver.set_virtual_wallet_behavior("wait"); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const controller = new AbortController(); | ||
| const options = makeCreateOptions({ protocol: "openid4vci", signal: controller.signal }); | ||
| const promise = navigator.credentials.create(options); | ||
|
|
||
| // Give it some time to make sure it's pending. | ||
| await new Promise(resolve => t.step_timeout(resolve, 100)); | ||
|
|
||
| controller.abort(); | ||
| await promise_rejects_dom(t, "AbortError", promise); | ||
| }, "navigator.credentials.create() with wait mode should remain pending until aborted."); | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <!DOCTYPE html> | ||
| <title>Digital Credential API: get() webdriver tests.</title> | ||
| <link rel="help" href="https://wicg.github.io/digital-credentials/"> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/resources/testdriver.js?feature=bidi"></script> | ||
| <script src="/resources/testdriver-vendor.js"></script> | ||
|
mohamedamir marked this conversation as resolved.
|
||
| <body></body> | ||
| <script type="module"> | ||
| import { makeGetOptions } from "../support/helper.js"; | ||
|
|
||
| promise_test(async (t) => { | ||
| const responseData = "test-response-data"; | ||
| await test_driver.set_virtual_wallet_behavior("respond", "openid4vp-v1-unsigned", { "value": responseData }); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" }); | ||
| const result = await navigator.credentials.get(options); | ||
|
|
||
| assert_equals(result.protocol, "openid4vp-v1-unsigned"); | ||
| assert_equals(result.data.value, responseData); | ||
| }, "navigator.credentials.get() with respond mode should resolve with the specified data."); | ||
|
|
||
| promise_test(async (t) => { | ||
| const complexData = { "a": 1, "b": [2, 3], "c": { "d": 4 } }; | ||
| await test_driver.set_virtual_wallet_behavior("respond", "openid4vp-v1-unsigned", complexData); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" }); | ||
| const result = await navigator.credentials.get(options); | ||
|
|
||
| assert_equals(result.protocol, "openid4vp-v1-unsigned"); | ||
| assert_equals(result.data.a, 1); | ||
| assert_array_equals(result.data.b, [2, 3]); | ||
| assert_equals(result.data.c.d, 4); | ||
| }, "navigator.credentials.get() with complex data response should resolve with structured data."); | ||
|
|
||
| promise_test(async (t) => { | ||
| await test_driver.set_virtual_wallet_behavior("decline"); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned" }); | ||
| await promise_rejects_dom(t, "NotAllowedError", navigator.credentials.get(options)); | ||
| }, "navigator.credentials.get() with decline mode should reject with NotAllowedError."); | ||
|
|
||
| promise_test(async (t) => { | ||
| await test_driver.set_virtual_wallet_behavior("wait"); | ||
| t.add_cleanup(() => test_driver.set_virtual_wallet_behavior("clear")); | ||
| await test_driver.bless("user activation"); | ||
|
|
||
| const controller = new AbortController(); | ||
| const options = makeGetOptions({ protocol: "openid4vp-v1-unsigned", signal: controller.signal }); | ||
| const promise = navigator.credentials.get(options); | ||
|
|
||
| // Give it some time to make sure it's pending. | ||
| await new Promise(resolve => t.step_timeout(resolve, 100)); | ||
|
|
||
| controller.abort(); | ||
| await promise_rejects_dom(t, "AbortError", promise); | ||
| }, "navigator.credentials.get() with wait mode should remain pending until aborted."); | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.