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
3 // found in the LICENSE file.
6 // Tests that attaching a named event twice will fail.
7 function doubleAttach() {
9 var onClicked = new chrome.Event("browserAction.onClicked");
10 var onClicked2 = new chrome.Event("browserAction.onClicked");
11 onClicked.addListener(dummy);
12 chrome.test.assertTrue(onClicked.hasListeners());
14 onClicked2.addListener(dummy);
17 chrome.test.assertTrue(
18 e.message.search("already attached") >= 0,
21 chrome.test.assertFalse(onClicked2.hasListeners());
22 onClicked2.removeListener(dummy);
24 onClicked.removeListener(dummy);
25 chrome.test.assertFalse(onClicked.hasListeners());
26 chrome.test.succeed();
29 // Tests that 2 pages attaching to the same event does not trigger a DCHECK.
30 function twoPageAttach() {
31 // Test harness should already have opened tab.html, which registers this
33 chrome.browserAction.onClicked.addListener(function() {});
35 // Test continues in twoPageAttach.html.
36 window.open("twoPageAttach.html");