OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 const notification = chrome.experimental.notification; | 5 const notifications = chrome.notifications; |
6 | 6 |
7 var idString = "foo"; | 7 var idString = "foo"; |
8 | 8 |
9 var testCSP = function() { | 9 var testCSP = function() { |
10 var onCreateCallback = function(id) { | 10 var onCreateCallback = function(id) { |
11 if (chrome.runtime.lastError) { | 11 if (chrome.runtime.lastError) { |
12 chrome.test.succeed(); | 12 chrome.test.succeed(); |
13 return; | 13 return; |
14 } | 14 } |
15 chrome.test.fail(); | 15 chrome.test.fail(); |
16 } | 16 } |
17 | 17 |
18 var options = { | 18 var options = { |
19 templateType: "basic", | 19 templateType: "basic", |
20 iconUrl: "http://google.com/clearly-a-security-problem.png", | 20 iconUrl: "http://google.com/clearly-a-security-problem.png", |
21 title: "Attention!", | 21 title: "Attention!", |
22 message: "Check out Cirque du Soleil" | 22 message: "Check out Cirque du Soleil" |
23 }; | 23 }; |
24 notification.create(idString, options, onCreateCallback); | 24 notifications.create(idString, options, onCreateCallback); |
25 }; | 25 }; |
26 | 26 |
27 function testDataURL() { | 27 function testDataURL() { |
28 chrome.runtime.lastError = undefined; | 28 chrome.runtime.lastError = undefined; |
29 var onCreateCallback = function(id) { | 29 var onCreateCallback = function(id) { |
30 if (chrome.runtime.lastError) { | 30 if (chrome.runtime.lastError) { |
31 chrome.test.fail(); | 31 chrome.test.fail(); |
32 return; | 32 return; |
33 } | 33 } |
34 chrome.test.succeed(); | 34 chrome.test.succeed(); |
35 } | 35 } |
36 var options = { | 36 var options = { |
37 templateType: "basic", | 37 templateType: "basic", |
38 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 38 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
39 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 39 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
40 "AAAABJRU5ErkJggg==", | 40 "AAAABJRU5ErkJggg==", |
41 title: "Attention!", | 41 title: "Attention!", |
42 message: "Check out Cirque du Soleil" | 42 message: "Check out Cirque du Soleil" |
43 }; | 43 }; |
44 notification.create(idString, options, onCreateCallback); | 44 notifications.create(idString, options, onCreateCallback); |
45 } | 45 } |
46 | 46 |
47 function testCSPUpdateIconURL() { | 47 function testCSPUpdateIconURL() { |
48 var onUpdateCallback = function(id) { | 48 var onUpdateCallback = function(id) { |
49 if (chrome.runtime.lastError) { | 49 if (chrome.runtime.lastError) { |
50 chrome.test.succeed(); | 50 chrome.test.succeed(); |
51 return; | 51 return; |
52 } | 52 } |
53 chrome.test.fail(); | 53 chrome.test.fail(); |
54 }; | 54 }; |
55 var onCreateCallback = function(id) { | 55 var onCreateCallback = function(id) { |
56 if (chrome.runtime.lastError) { | 56 if (chrome.runtime.lastError) { |
57 chrome.test.fail(); | 57 chrome.test.fail(); |
58 return; | 58 return; |
59 } | 59 } |
60 var options2 = { | 60 var options2 = { |
61 templateType: "basic", | 61 templateType: "basic", |
62 iconUrl: "http://www.google.com/favicon.ico", | 62 iconUrl: "http://www.google.com/favicon.ico", |
63 title: "Attention!", | 63 title: "Attention!", |
64 message: "Check out Cirque du Soleil" | 64 message: "Check out Cirque du Soleil" |
65 }; | 65 }; |
66 notification.update(idString, options2, onUpdateCallback); | 66 notifications.update(idString, options2, onUpdateCallback); |
67 } | 67 } |
68 var options = { | 68 var options = { |
69 templateType: "basic", | 69 templateType: "basic", |
70 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 70 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
71 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 71 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
72 "AAAABJRU5ErkJggg==", | 72 "AAAABJRU5ErkJggg==", |
73 title: "Attention!", | 73 title: "Attention!", |
74 message: "Check out Cirque du Soleil" | 74 message: "Check out Cirque du Soleil" |
75 }; | 75 }; |
76 notification.create(idString, options, onCreateCallback); | 76 notifications.create(idString, options, onCreateCallback); |
77 } | 77 } |
78 | 78 |
79 function testCSPUpdateImageURL() { | 79 function testCSPUpdateImageURL() { |
80 var onUpdateCallback = function(id) { | 80 var onUpdateCallback = function(id) { |
81 if (chrome.runtime.lastError) { | 81 if (chrome.runtime.lastError) { |
82 chrome.test.succeed(); | 82 chrome.test.succeed(); |
83 return; | 83 return; |
84 } | 84 } |
85 chrome.test.fail(); | 85 chrome.test.fail(); |
86 }; | 86 }; |
87 var onCreateCallback = function(id) { | 87 var onCreateCallback = function(id) { |
88 if (chrome.runtime.lastError) { | 88 if (chrome.runtime.lastError) { |
89 chrome.test.fail(); | 89 chrome.test.fail(); |
90 return; | 90 return; |
91 } | 91 } |
92 var options2 = { | 92 var options2 = { |
93 templateType: "basic", | 93 templateType: "basic", |
94 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 94 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
95 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 95 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
96 "AAAABJRU5ErkJggg==", | 96 "AAAABJRU5ErkJggg==", |
97 imageUrl: "http://www.google.com/favicon.ico", | 97 imageUrl: "http://www.google.com/favicon.ico", |
98 title: "Attention!", | 98 title: "Attention!", |
99 message: "Check out Cirque du Soleil" | 99 message: "Check out Cirque du Soleil" |
100 }; | 100 }; |
101 notification.update(idString, options2, onUpdateCallback); | 101 notifications.update(idString, options2, onUpdateCallback); |
102 } | 102 } |
103 var options = { | 103 var options = { |
104 templateType: "image", | 104 templateType: "image", |
105 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 105 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
106 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 106 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
107 "AAAABJRU5ErkJggg==", | 107 "AAAABJRU5ErkJggg==", |
108 imageUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 108 imageUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
109 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 109 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
110 "AAAABJRU5ErkJggg==", | 110 "AAAABJRU5ErkJggg==", |
111 title: "Attention!", | 111 title: "Attention!", |
112 message: "Check out Cirque du Soleil" | 112 message: "Check out Cirque du Soleil" |
113 }; | 113 }; |
114 notification.create(idString, options, onCreateCallback); | 114 notifications.create(idString, options, onCreateCallback); |
115 } | 115 } |
116 | 116 |
117 function testCSPUpdateButtonIconURL() { | 117 function testCSPUpdateButtonIconURL() { |
118 var onUpdateCallback = function(id) { | 118 var onUpdateCallback = function(id) { |
119 if (chrome.runtime.lastError) { | 119 if (chrome.runtime.lastError) { |
120 chrome.test.succeed(); | 120 chrome.test.succeed(); |
121 return; | 121 return; |
122 } | 122 } |
123 chrome.test.fail(); | 123 chrome.test.fail(); |
124 }; | 124 }; |
125 var onCreateCallback = function(id) { | 125 var onCreateCallback = function(id) { |
126 if (chrome.runtime.lastError) { | 126 if (chrome.runtime.lastError) { |
127 chrome.test.fail(); | 127 chrome.test.fail(); |
128 return; | 128 return; |
129 } | 129 } |
130 var options2 = { | 130 var options2 = { |
131 templateType: "basic", | 131 templateType: "basic", |
132 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 132 iconUrl: "xdata:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
dharcourt
2013/03/04 23:46:27
"xdata" -> "data"?
| |
133 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 133 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
134 "AAAABJRU5ErkJggg==", | 134 "AAAABJRU5ErkJggg==", |
135 title: "Attention!", | 135 title: "Attention!", |
136 buttons: [ { | 136 buttons: [ { |
137 title: "Foo", | 137 title: "Foo", |
138 iconUrl: "http://www.google.com/favicon.ico" | 138 iconUrl: "http://www.google.com/favicon.ico" |
139 } ], | 139 } ], |
140 message: "Check out Cirque du Soleil" | 140 message: "Check out Cirque du Soleil" |
141 }; | 141 }; |
142 notification.update(idString, options2, onUpdateCallback); | 142 notifications.update(idString, options2, onUpdateCallback); |
143 } | 143 } |
144 var options = { | 144 var options = { |
145 templateType: "basic", | 145 templateType: "basic", |
146 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 146 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
147 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 147 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
148 "AAAABJRU5ErkJggg==", | 148 "AAAABJRU5ErkJggg==", |
149 title: "Attention!", | 149 title: "Attention!", |
150 buttons: [ { | 150 buttons: [ { |
151 title: "Foo", | 151 title: "Foo", |
152 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 152 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
153 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 153 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
154 "AAAABJRU5ErkJggg==" | 154 "AAAABJRU5ErkJggg==" |
155 } ], | 155 } ], |
156 message: "Check out Cirque du Soleil" | 156 message: "Check out Cirque du Soleil" |
157 }; | 157 }; |
158 notification.create(idString, options, onCreateCallback); | 158 notifications.create(idString, options, onCreateCallback); |
159 } | 159 } |
160 chrome.test.runTests([ | 160 chrome.test.runTests([ |
161 testCSP, | 161 testCSP, |
162 testDataURL, | 162 testDataURL, |
163 testCSPUpdateIconURL, | 163 testCSPUpdateIconURL, |
164 testCSPUpdateImageURL, | 164 testCSPUpdateImageURL, |
165 testCSPUpdateButtonIconURL ]); | 165 testCSPUpdateButtonIconURL ]); |
OLD | NEW |