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

Unified Diff: chrome/test/data/notifications/platform_notification_service.html

Issue 1019803002: Add browser tests for loading notification icons from blob and data URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/notifications/platform_notification_service.html
diff --git a/chrome/test/data/notifications/platform_notification_service.html b/chrome/test/data/notifications/platform_notification_service.html
index 3c6ea37e2ad2376eaa6bcf2984f773bde2b6147d..e257635f26c7c4db0cdb4b0d662cc7c061525ecd 100644
--- a/chrome/test/data/notifications/platform_notification_service.html
+++ b/chrome/test/data/notifications/platform_notification_service.html
@@ -58,6 +58,49 @@
});
}
+ // Helper function to request icon.png, returns a promise that will be
johnme 2015/03/19 12:24:29 Nit: you could just use fetch
Peter Beverloo 2015/03/19 12:30:02 Done.
+ // resolved with the response's content when complete.
+ function RequestResource(url, type) {
+ return new Promise(function(resolve) {
+ var request = new XMLHttpRequest();
+ request.open('GET', url, true);
+ request.responseType = type;
+
+ request.onload = function() {
+ resolve(request.response);
+ };
+
+ request.send();
+ });
+ }
+
+ // Displays a persistent notification with a data: URL as its image.
+ function DisplayPersistentNotificationDataUrlImage() {
+ RequestResource('icon.png', 'arraybuffer').then(function(arrayBuffer) {
+ var uint8Array = new Uint8Array(arrayBuffer),
+ string = new Array(uint8Array.length);
+
+ for (var i = 0; i < uint8Array.length; ++i)
+ string[i] = String.fromCharCode(uint8Array[i]);
johnme 2015/03/19 12:24:29 I'm a little freaked out by the need to convert ev
Peter Beverloo 2015/03/19 12:30:02 Done.
+
+ var data = string.join('');
+ DisplayPersistentNotification('Data URL Title', {
+ body: 'Contents',
+ icon: 'data:image/png;base64,' + btoa(data)
+ })
+ });
+ }
+
+ // Displays a persistent notification with a blob URL as its image.
+ function DisplayPersistentNotificationBlobImage() {
+ RequestResource('icon.png', 'blob').then(function(blob) {
+ DisplayPersistentNotification('Blob Title', {
+ body: 'Contents',
+ icon: URL.createObjectURL(blob)
+ });
+ });
+ }
+
// Returns the latest received message from the worker. If no message has
// been received, nothing will be done. For successfully registered
// Service Workers this is OK, however, since the "message" event handler
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698