| 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.tabs.onUpdated.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("cannot be used in this context.") >= 0, |
| 16 e.message); | 16 e.message); |
| 17 } | 17 } |
| 18 chrome.test.assertFalse(chrome.tabs.onUpdated.hasListeners()); | |
| 19 chrome.tabs.onUpdated.removeListener(dummy); // browser should not DCHECK | |
| 20 chrome.test.succeed(); | 18 chrome.test.succeed(); |
| 21 }, | 19 }, |
| 22 | 20 |
| 23 // Tests that attaching a named event twice will fail. | 21 // Tests that attaching a named event twice will fail. |
| 24 function doubleAttach() { | 22 function doubleAttach() { |
| 25 function dummy() {}; | 23 function dummy() {}; |
| 26 var onClicked = new chrome.Event("browserAction.onClicked"); | 24 var onClicked = new chrome.Event("browserAction.onClicked"); |
| 27 var onClicked2 = new chrome.Event("browserAction.onClicked"); | 25 var onClicked2 = new chrome.Event("browserAction.onClicked"); |
| 28 onClicked.addListener(dummy); | 26 onClicked.addListener(dummy); |
| 29 chrome.test.assertTrue(onClicked.hasListeners()); | 27 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. | 44 // Tests that 2 pages attaching to the same event does not trigger a DCHECK. |
| 47 function twoPageAttach() { | 45 function twoPageAttach() { |
| 48 // Test harness should already have opened tab.html, which registers this | 46 // Test harness should already have opened tab.html, which registers this |
| 49 // listener. | 47 // listener. |
| 50 chrome.browserAction.onClicked.addListener(function() {}); | 48 chrome.browserAction.onClicked.addListener(function() {}); |
| 51 | 49 |
| 52 // Test continues in twoPageAttach.html. | 50 // Test continues in twoPageAttach.html. |
| 53 window.open("twoPageAttach.html"); | 51 window.open("twoPageAttach.html"); |
| 54 }, | 52 }, |
| 55 ]); | 53 ]); |
| OLD | NEW |