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

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: add test 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 unified diff | Download patch
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, InPageNavigations) {
65 NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
66
67 auto handlers = browser()->tab_strip_model()->GetActiveWebContents()
68 ->GetWebUI()->GetHandlersForTesting();
69 for (content::WebUIMessageHandler* handler : *handlers) {
Charlie Reis 2016/06/25 00:02:19 nit: No braces needed. Same below.
tommycli 2016/06/25 00:12:17 Done.
70 handler->AllowJavascriptForTesting();
71 }
72
73 // Push onto window.history. Back should now be an in-page navigation.
74 ASSERT_TRUE(content::ExecuteScript(
75 browser()->tab_strip_model()->GetActiveWebContents(),
76 "window.history.pushState({}, '', 'foo.html')"));
77 chrome::GoBack(browser(), CURRENT_TAB);
Charlie Reis 2016/06/25 00:02:19 You might need to use WaitForLoadStop to avoid fla
tommycli 2016/06/25 00:12:17 I didn't detect any flakiness on my machine (the t
78
79 for (content::WebUIMessageHandler* handler : *handlers) {
80 EXPECT_TRUE(handler->IsJavascriptAllowed());
81 }
82 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/webui/web_ui_impl.h » ('j') | content/browser/webui/web_ui_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698