forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update clipboard API calls to use clipboard permissions.
This adds permission checks to make sure that the user has granted appropriate permission for the clipboard API methods. Bug: 677564 Change-Id: I5af221b0e18d45509ff2a8c3856680e598a51dcb Reviewed-on: https://chromium-review.googlesource.com/804973 Reviewed-by: Antoine Labour <piman@chromium.org> Reviewed-by: Raymes Khoury <raymes@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Commit-Queue: Gary Kacmarcik <garykac@chromium.org> Cr-Commit-Position: refs/heads/master@{#525516}
- Loading branch information
Showing
15 changed files
with
356 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/clipboard/readtext-denied.https-expected.txt
This file contains 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,12 @@ | ||
Tests navigator.clipboard.readText() permission failure. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS PermissionsHelper.setPermission is defined. | ||
PASS navigator.clipboard is non-null. | ||
PASS clipboard.readText() fail (as expected). | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
34 changes: 34 additions & 0 deletions
34
third_party/WebKit/LayoutTests/clipboard/readtext-denied.https.html
This file contains 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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../http/tests/resources/permissions-helper.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Tests navigator.clipboard.readText() permission failure."); | ||
|
||
shouldBeDefined("PermissionsHelper.setPermission"); | ||
|
||
function successCallback(access) { | ||
testFailed( | ||
"clipboard.readText() does not fail (even though it really should have)."); | ||
finishJSTest(); | ||
} | ||
|
||
function errorCallback(error) { | ||
testPassed("clipboard.readText() fail (as expected)."); | ||
finishJSTest(); | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
|
||
PermissionsHelper.setPermission('clipboard-read', 'denied').then(function() { | ||
shouldBeNonNull("navigator.clipboard"); | ||
navigator.clipboard.readText().then(successCallback, errorCallback); | ||
}); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/clipboard/readtext-granted.https-expected.txt
This file contains 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,12 @@ | ||
Tests navigator.clipboard.readText() permission success. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS PermissionsHelper.setPermission is defined. | ||
PASS navigator.clipboard is non-null. | ||
PASS clipboard.readText() success (as expected). | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
34 changes: 34 additions & 0 deletions
34
third_party/WebKit/LayoutTests/clipboard/readtext-granted.https.html
This file contains 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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../http/tests/resources/permissions-helper.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Tests navigator.clipboard.readText() permission success."); | ||
|
||
shouldBeDefined("PermissionsHelper.setPermission"); | ||
|
||
function successCallback(access) { | ||
testPassed("clipboard.readText() success (as expected)."); | ||
finishJSTest(); | ||
} | ||
|
||
function errorCallback(error) { | ||
testFailed( | ||
"clipboard.readText() does not fail (even though we hoped it would)."); | ||
finishJSTest(); | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
|
||
PermissionsHelper.setPermission('clipboard-read', 'granted').then(function() { | ||
shouldBeNonNull("navigator.clipboard"); | ||
navigator.clipboard.readText().then(successCallback, errorCallback); | ||
}); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/clipboard/writetext-denied.https-expected.txt
This file contains 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,12 @@ | ||
Tests navigator.clipboard.writeText() permission failure. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS PermissionsHelper.setPermission is defined. | ||
PASS navigator.clipboard is non-null. | ||
PASS clipboard.writeText() fail (as expected). | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
34 changes: 34 additions & 0 deletions
34
third_party/WebKit/LayoutTests/clipboard/writetext-denied.https.html
This file contains 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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../http/tests/resources/permissions-helper.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Tests navigator.clipboard.writeText() permission failure."); | ||
|
||
shouldBeDefined("PermissionsHelper.setPermission"); | ||
|
||
function successCallback(access) { | ||
testFailed( | ||
"clipboard.writeText() does not fail (even though it really should have)."); | ||
finishJSTest(); | ||
} | ||
|
||
function errorCallback(error) { | ||
testPassed("clipboard.writeText() fail (as expected)."); | ||
finishJSTest(); | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
|
||
PermissionsHelper.setPermission('clipboard-write', 'denied').then(function() { | ||
shouldBeNonNull("navigator.clipboard"); | ||
navigator.clipboard.writeText("xyz").then(successCallback, errorCallback); | ||
}); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
third_party/WebKit/LayoutTests/clipboard/writetext-granted.https-expected.txt
This file contains 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,12 @@ | ||
Tests navigator.clipboard.writeText() permission success. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS PermissionsHelper.setPermission is defined. | ||
PASS navigator.clipboard is non-null. | ||
PASS clipboard.writeText() success (as expected). | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
34 changes: 34 additions & 0 deletions
34
third_party/WebKit/LayoutTests/clipboard/writetext-granted.https.html
This file contains 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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../resources/js-test.js"></script> | ||
<script src="../http/tests/resources/permissions-helper.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Tests navigator.clipboard.writeText() permission success."); | ||
|
||
shouldBeDefined("PermissionsHelper.setPermission"); | ||
|
||
function successCallback(access) { | ||
testPassed("clipboard.writeText() success (as expected)."); | ||
finishJSTest(); | ||
} | ||
|
||
function errorCallback(error) { | ||
testFailed( | ||
"clipboard.writeText() does not fail (even though we hoped it would)."); | ||
finishJSTest(); | ||
} | ||
|
||
window.jsTestIsAsync = true; | ||
|
||
PermissionsHelper.setPermission('clipboard-write', 'granted').then(function() { | ||
shouldBeNonNull("navigator.clipboard"); | ||
navigator.clipboard.writeText("xyz").then(successCallback, errorCallback); | ||
}); | ||
|
||
|
||
</script> | ||
</body> | ||
</html> |
This file contains 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.