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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/webui/web_ui_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc b/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
index f054a8138bacc13ad5f19903376645b435b4c793..b86a704beaa9f064410240b1f24c7b2e9aa07ab8 100644
--- a/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
@@ -60,3 +60,33 @@ IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ToggleJavaScript) {
handler->AllowJavascriptForTesting();
}
}
+
+IN_PROC_BROWSER_TEST_F(MdSettingsUITest, InPageNavigationsAndReload) {
+ NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
+
+ auto handlers = browser()->tab_strip_model()->GetActiveWebContents()
+ ->GetWebUI()->GetHandlersForTesting();
+ for (content::WebUIMessageHandler* handler : *handlers)
+ handler->AllowJavascriptForTesting();
+
+ // Push onto window.history. Back should now be an in-page navigation.
+ ASSERT_TRUE(content::ExecuteScript(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "window.history.pushState({}, '', 'foo.html')"));
+ chrome::GoBack(browser(), CURRENT_TAB);
+ WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
+
+ for (content::WebUIMessageHandler* handler : *handlers)
+ EXPECT_TRUE(handler->IsJavascriptAllowed());
+
+ chrome::Reload(browser(), CURRENT_TAB);
+ WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
+
+ // 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
+ bool all_handlers_allowed = true;
+ for (content::WebUIMessageHandler* handler : *handlers) {
+ if (!handler->IsJavascriptAllowed())
+ all_handlers_allowed = false;
+ }
+ EXPECT_FALSE(all_handlers_allowed);
+}
« 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