Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: chrome/test/data/extensions/api_test/events/background.js

Issue 15841013: Make miscellaneous_bindings and event_bindings Required as needed. Previously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/devtools/extensions/devtools_messaging/devtools.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.management.onEnabled.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.management.onEnabled.hasListeners()); 18 chrome.test.assertFalse(chrome.management.onEnabled.hasListeners());
19 // Browser should not DCHECK. 19 // Browser should not DCHECK.
20 chrome.management.onEnabled.removeListener(dummy); 20 chrome.management.onEnabled.removeListener(dummy);
21 chrome.test.succeed(); 21 chrome.test.succeed();
22 }, 22 },
23 23
24 // Tests that attaching a named event twice will fail. 24 // Tests that attaching a named event twice will fail.
25 function doubleAttach() { 25 function doubleAttach() {
26 function dummy() {}; 26 function dummy() {};
27 var onClicked = new chrome.Event("browserAction.onClicked"); 27 var onClicked = chrome.test.createEvent("browserAction.onClicked");
28 var onClicked2 = new chrome.Event("browserAction.onClicked"); 28 var onClicked2 = chrome.test.createEvent("browserAction.onClicked");
29 onClicked.addListener(dummy); 29 onClicked.addListener(dummy);
30 chrome.test.assertTrue(onClicked.hasListeners()); 30 chrome.test.assertTrue(onClicked.hasListeners());
31 try { 31 try {
32 onClicked2.addListener(dummy); 32 onClicked2.addListener(dummy);
33 chrome.test.fail(); 33 chrome.test.fail();
34 } catch (e) { 34 } catch (e) {
35 chrome.test.assertTrue( 35 chrome.test.assertTrue(
36 e.message.search("already attached") >= 0, 36 e.message.search("already attached") >= 0,
37 e.message); 37 e.message);
38 } 38 }
39 chrome.test.assertFalse(onClicked2.hasListeners()); 39 chrome.test.assertFalse(onClicked2.hasListeners());
40 onClicked2.removeListener(dummy); 40 onClicked2.removeListener(dummy);
41 41
42 onClicked.removeListener(dummy); 42 onClicked.removeListener(dummy);
43 chrome.test.assertFalse(onClicked.hasListeners()); 43 chrome.test.assertFalse(onClicked.hasListeners());
44 chrome.test.succeed(); 44 chrome.test.succeed();
45 }, 45 },
46 46
47 // 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.
48 function twoPageAttach() { 48 function twoPageAttach() {
49 // Test harness should already have opened tab.html, which registers this 49 // Test harness should already have opened tab.html, which registers this
50 // listener. 50 // listener.
51 chrome.browserAction.onClicked.addListener(function() {}); 51 chrome.browserAction.onClicked.addListener(function() {});
52 52
53 // Test continues in twoPageAttach.html. 53 // Test continues in twoPageAttach.html.
54 window.open("twoPageAttach.html"); 54 window.open("twoPageAttach.html");
55 }, 55 },
56 ]); 56 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/devtools/extensions/devtools_messaging/devtools.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698