Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / notifications / api / csp / background.js
blob9c066d4b67daada7aa3a743bcd2cd3c69ae739b7
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
3 // found in the LICENSE file.
5 const notifications = chrome.notifications;
7 var idString = "foo";
9 var testCSP = function() {
10 var onCreateCallback = function(id) {
11 if (chrome.runtime.lastError) {
12 chrome.test.succeed();
13 return;
15 chrome.test.fail();
18 var options = {
19 type: "basic",
20 iconUrl: "http://google.com/clearly-a-security-problem.png",
21 title: "Attention!",
22 message: "Check out Cirque du Soleil"
24 notifications.create(idString, options, onCreateCallback);
27 function testDataURL() {
28 chrome.runtime.lastError = undefined;
29 var onCreateCallback = function(id) {
30 if (chrome.runtime.lastError) {
31 chrome.test.fail();
32 return;
34 chrome.test.succeed();
36 var options = {
37 type: "basic",
38 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
39 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
40 "AAAABJRU5ErkJggg==",
41 title: "Attention!",
42 message: "Check out Cirque du Soleil"
44 notifications.create(idString, options, onCreateCallback);
47 function testCSPUpdateIconURL() {
48 var onUpdateCallback = function(id) {
49 if (chrome.runtime.lastError) {
50 chrome.test.succeed();
51 return;
53 chrome.test.fail();
55 var onCreateCallback = function(id) {
56 if (chrome.runtime.lastError) {
57 chrome.test.fail();
58 return;
60 var options2 = {
61 type: "basic",
62 iconUrl: "http://www.google.com/favicon.ico",
63 title: "Attention!",
64 message: "Check out Cirque du Soleil"
66 notifications.update(idString, options2, onUpdateCallback);
68 var options = {
69 type: "basic",
70 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
71 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
72 "AAAABJRU5ErkJggg==",
73 title: "Attention!",
74 message: "Check out Cirque du Soleil"
76 notifications.create(idString, options, onCreateCallback);
79 function testCSPUpdateImageURL() {
80 var onUpdateCallback = function(id) {
81 if (chrome.runtime.lastError) {
82 chrome.test.succeed();
83 return;
85 chrome.test.fail();
87 var onCreateCallback = function(id) {
88 if (chrome.runtime.lastError) {
89 chrome.test.fail();
90 return;
92 var options2 = {
93 type: "basic",
94 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
95 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
96 "AAAABJRU5ErkJggg==",
97 imageUrl: "http://www.google.com/favicon.ico",
98 title: "Attention!",
99 message: "Check out Cirque du Soleil"
101 notifications.update(idString, options2, onUpdateCallback);
103 var options = {
104 type: "image",
105 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
106 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
107 "AAAABJRU5ErkJggg==",
108 imageUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
109 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
110 "AAAABJRU5ErkJggg==",
111 title: "Attention!",
112 message: "Check out Cirque du Soleil"
114 notifications.create(idString, options, onCreateCallback);
117 function testCSPUpdateButtonIconURL() {
118 var onUpdateCallback = function(id) {
119 if (chrome.runtime.lastError) {
120 chrome.test.succeed();
121 return;
123 chrome.test.fail();
125 var onCreateCallback = function(id) {
126 if (chrome.runtime.lastError) {
127 chrome.test.fail();
128 return;
130 var options2 = {
131 type: "basic",
132 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
133 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
134 "AAAABJRU5ErkJggg==",
135 title: "Attention!",
136 buttons: [ {
137 title: "Foo",
138 iconUrl: "http://www.google.com/favicon.ico"
139 } ],
140 message: "Check out Cirque du Soleil"
142 notifications.update(idString, options2, onUpdateCallback);
144 var options = {
145 type: "basic",
146 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
147 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
148 "AAAABJRU5ErkJggg==",
149 title: "Attention!",
150 buttons: [ {
151 title: "Foo",
152 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" +
153 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" +
154 "AAAABJRU5ErkJggg=="
155 } ],
156 message: "Check out Cirque du Soleil"
158 notifications.create(idString, options, onCreateCallback);
160 chrome.test.runTests([
161 testCSP,
162 testDataURL,
163 testCSPUpdateIconURL,
164 testCSPUpdateImageURL,
165 testCSPUpdateButtonIconURL ]);