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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html lang="en"> 2 <html lang="en">
3 <head> 3 <head>
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <title>Platform Notification Service BrowserTest service page</title> 5 <title>Platform Notification Service BrowserTest service page</title>
6 </head> 6 </head>
7 <body> 7 <body>
8 <!-- This page is intended to be used by the cross-platform 8 <!-- This page is intended to be used by the cross-platform
9 PlatformNotificationServiceBrowserTest. --> 9 PlatformNotificationServiceBrowserTest. -->
10 <script src="notification_test_utils.js"></script> 10 <script src="notification_test_utils.js"></script>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 DisplayPersistentNotification('Title', { 51 DisplayPersistentNotification('Title', {
52 dir: 'rtl', 52 dir: 'rtl',
53 lang: 'nl-NL', 53 lang: 'nl-NL',
54 body: 'Contents', 54 body: 'Contents',
55 tag: 'replace-id', 55 tag: 'replace-id',
56 icon: 'icon.png', 56 icon: 'icon.png',
57 silent: true 57 silent: true
58 }); 58 });
59 } 59 }
60 60
61 // 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.
62 // resolved with the response's content when complete.
63 function RequestResource(url, type) {
64 return new Promise(function(resolve) {
65 var request = new XMLHttpRequest();
66 request.open('GET', url, true);
67 request.responseType = type;
68
69 request.onload = function() {
70 resolve(request.response);
71 };
72
73 request.send();
74 });
75 }
76
77 // Displays a persistent notification with a data: URL as its image.
78 function DisplayPersistentNotificationDataUrlImage() {
79 RequestResource('icon.png', 'arraybuffer').then(function(arrayBuffer) {
80 var uint8Array = new Uint8Array(arrayBuffer),
81 string = new Array(uint8Array.length);
82
83 for (var i = 0; i < uint8Array.length; ++i)
84 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.
85
86 var data = string.join('');
87 DisplayPersistentNotification('Data URL Title', {
88 body: 'Contents',
89 icon: 'data:image/png;base64,' + btoa(data)
90 })
91 });
92 }
93
94 // Displays a persistent notification with a blob URL as its image.
95 function DisplayPersistentNotificationBlobImage() {
96 RequestResource('icon.png', 'blob').then(function(blob) {
97 DisplayPersistentNotification('Blob Title', {
98 body: 'Contents',
99 icon: URL.createObjectURL(blob)
100 });
101 });
102 }
103
61 // Returns the latest received message from the worker. If no message has 104 // Returns the latest received message from the worker. If no message has
62 // been received, nothing will be done. For successfully registered 105 // been received, nothing will be done. For successfully registered
63 // Service Workers this is OK, however, since the "message" event handler 106 // Service Workers this is OK, however, since the "message" event handler
64 // in DisplayPersistentNotification will take care of notifying the DOM 107 // in DisplayPersistentNotification will take care of notifying the DOM
65 // Automation Controller instead. 108 // Automation Controller instead.
66 function GetMessageFromWorker() { 109 function GetMessageFromWorker() {
67 if (!messageStack.length) { 110 if (!messageStack.length) {
68 expectingMessage = true; 111 expectingMessage = true;
69 return; 112 return;
70 } 113 }
71 114
72 domAutomationController.send('' + messageStack.pop()); 115 domAutomationController.send('' + messageStack.pop());
73 } 116 }
74 </script> 117 </script>
75 </body> 118 </body>
76 </html> 119 </html>
OLDNEW
« 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