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

Side by Side Diff: chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc

Issue 2099563002: WebUI: DisallowJavascript only on Refresh and non-same-page navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: name fix Created 4 years, 5 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 | content/browser/webui/web_ui_impl.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <string> 5 #include <string>
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_commands.h" 8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 auto handlers = browser()->tab_strip_model()->GetActiveWebContents() 54 auto handlers = browser()->tab_strip_model()->GetActiveWebContents()
55 ->GetWebUI()->GetHandlersForTesting(); 55 ->GetWebUI()->GetHandlersForTesting();
56 56
57 for (content::WebUIMessageHandler* handler : *handlers) { 57 for (content::WebUIMessageHandler* handler : *handlers) {
58 handler->AllowJavascriptForTesting(); 58 handler->AllowJavascriptForTesting();
59 handler->DisallowJavascript(); 59 handler->DisallowJavascript();
60 handler->AllowJavascriptForTesting(); 60 handler->AllowJavascriptForTesting();
61 } 61 }
62 } 62 }
63
64 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, InPageNavigationsAndReload) {
65 NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
66
67 auto handlers = browser()->tab_strip_model()->GetActiveWebContents()
68 ->GetWebUI()->GetHandlersForTesting();
69 for (content::WebUIMessageHandler* handler : *handlers)
70 handler->AllowJavascriptForTesting();
71
72 // Push onto window.history. Back should now be an in-page navigation.
73 ASSERT_TRUE(content::ExecuteScript(
74 browser()->tab_strip_model()->GetActiveWebContents(),
75 "window.history.pushState({}, '', 'foo.html')"));
76 chrome::GoBack(browser(), CURRENT_TAB);
77 WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
78
79 for (content::WebUIMessageHandler* handler : *handlers)
80 EXPECT_TRUE(handler->IsJavascriptAllowed());
81
82 chrome::Reload(browser(), CURRENT_TAB);
83 WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
84
85 // Verify that after a reload, at least some of the handlers are disallowed.
Charlie Reis 2016/06/25 00:17:02 I'm not sure I understand this. Wouldn't all of t
tommycli 2016/06/25 00:21:51 Some of the handlers only are used on subpages. Th
tommycli 2016/06/25 00:22:50 I'm trying to test that on Reload, the handlers ar
Charlie Reis 2016/06/27 21:31:31 Hmm. Would the list of enabled handlers match the
tommycli 2016/06/27 21:56:08 Ah yes. Using the test handler was the best sugges
86 bool all_handlers_allowed = true;
87 for (content::WebUIMessageHandler* handler : *handlers) {
88 if (!handler->IsJavascriptAllowed())
89 all_handlers_allowed = false;
90 }
91 EXPECT_FALSE(all_handlers_allowed);
92 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/webui/web_ui_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698