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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc

Issue 19045002: Use Blink support to watch CSS selectors directly instead of using a MutationObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial Created 7 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_action.h" 5 #include "chrome/browser/extensions/extension_action.h"
6 #include "chrome/browser/extensions/extension_action_manager.h" 6 #include "chrome/browser/extensions/extension_action_manager.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_tab_util.h" 8 #include "chrome/browser/extensions/extension_tab_util.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/extensions/test_extension_dir.h" 10 #include "chrome/browser/extensions/test_extension_dir.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // than waiting for the extension to run. 89 // than waiting for the extension to run.
90 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); 90 EXPECT_TRUE(page_action->GetIsVisible(tab_id));
91 91
92 // Make sure leaving a matching page unshows the page action. 92 // Make sure leaving a matching page unshows the page action.
93 NavigateInRenderer(tab, GURL("http://not_checked/")); 93 NavigateInRenderer(tab, GURL("http://not_checked/"));
94 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); 94 EXPECT_FALSE(page_action->GetIsVisible(tab_id));
95 95
96 // Insert a password field to make sure that's noticed. 96 // Insert a password field to make sure that's noticed.
97 ASSERT_TRUE(content::ExecuteScript( 97 ASSERT_TRUE(content::ExecuteScript(
98 tab, "document.body.innerHTML = '<input type=\"password\">';")); 98 tab, "document.body.innerHTML = '<input type=\"password\">';"));
99 // Give the mutation observer a chance to run and send back the 99 // Give the style match a chance to run and send back the matching-selector
100 // matching-selector update. 100 // update. This takes two times through the event loop.
101 ASSERT_TRUE(content::ExecuteScript(tab, std::string()));
101 ASSERT_TRUE(content::ExecuteScript(tab, std::string())); 102 ASSERT_TRUE(content::ExecuteScript(tab, std::string()));
Matt Perry 2013/10/02 22:20:22 This double call looks fishy. Are you just calling
Jeffrey Yasskin 2013/10/03 00:31:57 It's to force a RunMessageLoop in the Blink proces
102 EXPECT_TRUE(page_action->GetIsVisible(tab_id)) 103 EXPECT_TRUE(page_action->GetIsVisible(tab_id))
103 << "Adding a matching element should show the page action."; 104 << "Adding a matching element should show the page action.";
104 105
105 // Remove it again to make sure that reverts the action. 106 // Remove it again to make sure that reverts the action.
106 ASSERT_TRUE(content::ExecuteScript( 107 ASSERT_TRUE(content::ExecuteScript(
107 tab, "document.body.innerHTML = 'Hello world';")); 108 tab, "document.body.innerHTML = 'Hello world';"));
108 // Give the mutation observer a chance to run and send back the 109 // Give the mutation observer a chance to run and send back the
109 // matching-selector update. 110 // matching-selector update.
110 ASSERT_TRUE(content::ExecuteScript(tab, std::string())); 111 ASSERT_TRUE(content::ExecuteScript(tab, std::string()));
111 EXPECT_FALSE(page_action->GetIsVisible(tab_id)) 112 EXPECT_FALSE(page_action->GetIsVisible(tab_id))
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 " new PageStateMatcher({css: ['div input']});\n" 227 " new PageStateMatcher({css: ['div input']});\n"
227 " Return('Failed to throw');\n" 228 " Return('Failed to throw');\n"
228 "} catch (e) {\n" 229 "} catch (e) {\n"
229 " Return(e.message);\n" 230 " Return(e.message);\n"
230 "}\n"), 231 "}\n"),
231 testing::ContainsRegex("compound selector.*: div input$")); 232 testing::ContainsRegex("compound selector.*: div input$"));
232 } 233 }
233 234
234 } // namespace 235 } // namespace
235 } // namespace extensions 236 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_renderer.gypi » ('j') | chrome/renderer/extensions/content_watcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698