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

Side by Side Diff: chrome/browser/extensions/events_apitest.cc

Issue 1083663004: Revert of Move the event attach/detach logic on unload from event.js to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/events_are_unregistered/manifest.json » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include "extensions/browser/event_router.h"
8 #include "extensions/browser/extension_registry.h"
9
10 namespace extensions {
11
12 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Events) { 7 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Events) {
13 ASSERT_TRUE(RunExtensionTest("events")) << message_; 8 ASSERT_TRUE(RunExtensionTest("events")) << message_;
14 } 9 }
15
16 // Tests that events are unregistered when an extension page shuts down.
17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, EventsAreUnregistered) {
18 // In this test, page1.html registers for a number of events, then navigates
19 // to page2.html, which should unregister those events. page2.html notifies
20 // pass, by which point the event should have been unregistered.
21 EventRouter* event_router = EventRouter::Get(profile());
22 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
23
24 std::string test_extension_name = "events_are_unregistered";
25 ASSERT_TRUE(RunExtensionSubtest(test_extension_name, "page1.html"))
26 << message_;
27
28 // Find the extension we just installed by looking for the path.
29 const Extension* extension =
30 GetExtensionByPath(registry->enabled_extensions(),
31 test_data_dir_.AppendASCII(test_extension_name));
32 ASSERT_TRUE(extension);
33 std::string id = extension->id();
34
35 // The page has closed, so no matter what all events are no longer listened
36 // to.
37 EXPECT_FALSE(
38 event_router->ExtensionHasEventListener(id, "browserAction.onClicked"));
39 EXPECT_FALSE(
40 event_router->ExtensionHasEventListener(id, "runtime.onStartup"));
41 EXPECT_FALSE(
42 event_router->ExtensionHasEventListener(id, "runtime.onSuspend"));
43 EXPECT_FALSE(
44 event_router->ExtensionHasEventListener(id, "runtime.onInstalled"));
45 }
46
47 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/events_are_unregistered/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698