Skip to content

Commit

Permalink
Clipboard API Tests: Move permissions tests to WPT.
Browse files Browse the repository at this point in the history
Since #20461 and
#5671 were fixed, it now
becomes possible to automate some Web Platform Tests, and have them run
on all browsers automatically.

Clipboard API permission tests were previously outside WPT in order to
automate permissions using PermissionsHelper and detect regressions.

This allows us to share our permissions tests with other browsers
testing using WPT.

Bug: 1076691
Change-Id: I1ff6a8bbdf60b8d77fd8621efce840739fbeec23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2200278
Auto-Submit: Darwin Huang <huangdarwin@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769171}
  • Loading branch information
Darwin Huang authored and chromium-wpt-export-bot committed May 15, 2020
1 parent 5905cf0 commit 27acc7f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clipboard-apis/permissions/readText-denied.https.html
@@ -0,0 +1,17 @@
<!doctype html>
<meta charset="utf-8">
<title>navigator.clipboard.readText() fails when permission denied</title>
<link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api">
<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>
'use strict';

promise_test(async t => {
test_driver.set_permission({name: 'clipboard-read'}, 'denied');
await promise_rejects_dom(t,
'NotAllowedError', navigator.clipboard.readText());
}, 'navigator.clipboard.readText() fails when permission denied');
</script>
16 changes: 16 additions & 0 deletions clipboard-apis/permissions/readText-granted.https.html
@@ -0,0 +1,16 @@
<!doctype html>
<meta charset="utf-8">
<title>navigator.clipboard.readText() succeeds when permission granted</title>
<link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api">
<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>
'use strict';

promise_test(async () => {
test_driver.set_permission({name: 'clipboard-read'}, 'granted');
await navigator.clipboard.readText();
}, 'navigator.clipboard.readText() succeeds when permission granted');
</script>
17 changes: 17 additions & 0 deletions clipboard-apis/permissions/writeText-denied.https.html
@@ -0,0 +1,17 @@
<!doctype html>
<meta charset="utf-8">
<title>navigator.clipboard.writeText() fails when permission denied</title>
<link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api">
<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>
'use strict';

promise_test(async t => {
test_driver.set_permission({name: 'clipboard-write'}, 'denied');
await promise_rejects_dom(t, 'NotAllowedError',
navigator.clipboard.writeText('xyz'));
}, 'navigator.clipboard.writeText() fails when permission denied');
</script>
16 changes: 16 additions & 0 deletions clipboard-apis/permissions/writeText-granted.https.html
@@ -0,0 +1,16 @@
<!doctype html>
<meta charset="utf-8">
<title>navigator.clipboard.writeText() succeeds when permission granted</title>
<link rel="help" href="https://w3c.github.io/clipboard-apis/#async-clipboard-api">
<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>
'use strict';

promise_test(async () => {
test_driver.set_permission({name: 'clipboard-write'}, 'granted');
await navigator.clipboard.writeText('xyz');
}, 'navigator.clipboard.writeText() succeeds when permission granted');
</script>

0 comments on commit 27acc7f

Please sign in to comment.