Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: LayoutTests/push_messaging/push-messaging-has-permission.html

Issue 676003002: Add layout tests for hasPermission (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@push_has_permission
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/push_messaging/push-messaging-has-permission.html
diff --git a/LayoutTests/push_messaging/push-messaging-has-permission.html b/LayoutTests/push_messaging/push-messaging-has-permission.html
new file mode 100644
index 0000000000000000000000000000000000000000..0aa22677b5e9fa25e9b65b369c0a5873781f9c88
--- /dev/null
+++ b/LayoutTests/push_messaging/push-messaging-has-permission.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src='../resources/js-test.js'></script>
Michael van Ouwerkerk 2014/10/24 12:53:01 nit: double quotes for html attributes please
Miguel Garcia 2014/10/31 17:04:47 Done.
+</head>
+<body>
+<script>
+description('Tests for the Push API has permission method.');
Michael van Ouwerkerk 2014/10/24 12:53:01 hasPermission
Miguel Garcia 2014/10/31 17:04:47 Done.
+
+if (!window.testRunner)
+ debug('This test can not run without testRunner');
+
+window.jsTestIsAsync = true;
+
+function testPushHasPermissionDefault() {
+ window.testRunner.setMockPushClientError('permission_default');
+ testPushHasPermission('default', testPushHasPermissionDenied);
+}
+
+function testPushHasPermissionDenied() {
+ window.testRunner.setMockPushClientError('deny_permission');
+ testPushHasPermission('denied', testPushHasPermissionGranted);
+}
+
+function testPushHasPermissionGranted() {
+ window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId');
+ testPushHasPermission('granted');
+}
+
+function testPushHasPermission(expectedStatus, runNext) {
+ navigator.push.hasPermission().then(function(permissionStatus) {
+ status = permissionStatus;
Peter Beverloo 2014/10/24 13:03:24 nit: double space before the =
Miguel Garcia 2014/10/31 17:04:47 Done.
+ shouldBeEqualToString('status', expectedStatus);
Peter Beverloo 2014/10/24 13:03:24 shouldBeEqualToString('status', 'expectedStatus')
Miguel Garcia 2014/10/31 17:04:47 Oh, here it still matters, see previous comment.
+ if (runNext)
+ runNext();
+ else
+ finishJSTest();
+ }, function() {
+ testFailed('Error callback invoked unexpectedly.');
Peter Beverloo 2014/10/24 13:03:24 s/Error callback invoked/Promise rejected/.
Miguel Garcia 2014/10/31 17:04:47 Done
+ finishJSTest();
+ });
+}
+
+testPushHasPermissionDefault();
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698