OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 chrome.test.runTests([ | 5 chrome.test.runTests([ |
6 // Tests that attaching and detaching to an event for which we don't have | 6 // Tests that attaching and detaching to an event for which we don't have |
7 // permission acts as expected (e.g. we don't DCHECK!). | 7 // permission acts as expected (e.g. we don't DCHECK!). |
8 function attachAndDetachNoPermisssions() { | 8 function attachAndDetachNoPermisssions() { |
9 function dummy() {}; | 9 function dummy() {}; |
10 try { | 10 try { |
11 chrome.tabs.onUpdated.addListener(dummy); | 11 chrome.management.onEnabled.addListener(dummy); |
12 chrome.test.fail(); | 12 chrome.test.fail(); |
13 } catch (e) { | 13 } catch (e) { |
14 chrome.test.assertTrue( | 14 chrome.test.assertTrue( |
15 e.message.search("You do not have permission") >= 0, | 15 e.message.search("You do not have permission") >= 0, |
16 e.message); | 16 e.message); |
17 } | 17 } |
18 chrome.test.assertFalse(chrome.tabs.onUpdated.hasListeners()); | 18 chrome.test.assertFalse(chrome.management.onEnabled.hasListeners()); |
19 chrome.tabs.onUpdated.removeListener(dummy); // browser should not DCHECK | 19 // Browser should not DCHECK. |
| 20 chrome.management.onEnabled.removeListener(dummy); |
20 chrome.test.succeed(); | 21 chrome.test.succeed(); |
21 }, | 22 }, |
22 | 23 |
23 // Tests that attaching a named event twice will fail. | 24 // Tests that attaching a named event twice will fail. |
24 function doubleAttach() { | 25 function doubleAttach() { |
25 function dummy() {}; | 26 function dummy() {}; |
26 var onClicked = new chrome.Event("browserAction.onClicked"); | 27 var onClicked = new chrome.Event("browserAction.onClicked"); |
27 var onClicked2 = new chrome.Event("browserAction.onClicked"); | 28 var onClicked2 = new chrome.Event("browserAction.onClicked"); |
28 onClicked.addListener(dummy); | 29 onClicked.addListener(dummy); |
29 chrome.test.assertTrue(onClicked.hasListeners()); | 30 chrome.test.assertTrue(onClicked.hasListeners()); |
(...skipping 16 matching lines...) Expand all Loading... |
46 // Tests that 2 pages attaching to the same event does not trigger a DCHECK. | 47 // Tests that 2 pages attaching to the same event does not trigger a DCHECK. |
47 function twoPageAttach() { | 48 function twoPageAttach() { |
48 // Test harness should already have opened tab.html, which registers this | 49 // Test harness should already have opened tab.html, which registers this |
49 // listener. | 50 // listener. |
50 chrome.browserAction.onClicked.addListener(function() {}); | 51 chrome.browserAction.onClicked.addListener(function() {}); |
51 | 52 |
52 // Test continues in twoPageAttach.html. | 53 // Test continues in twoPageAttach.html. |
53 window.open("twoPageAttach.html"); | 54 window.open("twoPageAttach.html"); |
54 }, | 55 }, |
55 ]); | 56 ]); |
OLD | NEW |