| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 const notification = chrome.experimental.notification; | |
| 6 var theOnlyTestDone = null; | |
| 7 | |
| 8 var notificationData = { | |
| 9 templateType: "basic", | |
| 10 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | |
| 11 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | |
| 12 "AAAABJRU5ErkJggg==", | |
| 13 title: "Attention!", | |
| 14 message: "Check out Cirque du Soleil" | |
| 15 }; | |
| 16 | |
| 17 var results = { | |
| 18 FOO: false, | |
| 19 BAR: true, | |
| 20 BAT: false, | |
| 21 BIFF: false, | |
| 22 BLAT: true, | |
| 23 BLOT: true | |
| 24 }; | |
| 25 | |
| 26 function createCallback(id) { } | |
| 27 | |
| 28 var onClosedHooks = { | |
| 29 BIFF: function() { | |
| 30 notification.create("BLAT", notificationData, createCallback); | |
| 31 notification.create("BLOT", notificationData, createCallback); | |
| 32 }, | |
| 33 }; | |
| 34 | |
| 35 function onClosedListener(id, by_user) { | |
| 36 if (results[id] !== by_user) { | |
| 37 chrome.test.notifyFail("Notification " + id + | |
| 38 " closed with bad by_user param ( "+ by_user +" )"); | |
| 39 return; | |
| 40 } | |
| 41 chrome.test.notifyPass(); | |
| 42 delete results[id]; | |
| 43 | |
| 44 if (typeof onClosedHooks[id] === "function") | |
| 45 onClosedHooks[id](); | |
| 46 | |
| 47 if (Object.keys(results).length === 0) | |
| 48 theOnlyTestDone(); | |
| 49 } | |
| 50 | |
| 51 notification.onClosed.addListener(onClosedListener); | |
| 52 | |
| 53 function theOnlyTest() { | |
| 54 theOnlyTestDone = chrome.test.callbackAdded(); | |
| 55 | |
| 56 notification.create("FOO", notificationData, createCallback); | |
| 57 notification.create("BAR", notificationData, createCallback); | |
| 58 notification.create("BAT", notificationData, createCallback); | |
| 59 notification.create("BIFF", notificationData, createCallback); | |
| 60 } | |
| 61 | |
| 62 chrome.test.runTests([ theOnlyTest ]); | |
| OLD | NEW |