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

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

Issue 2919663002: MD Settings: change how valid origins are checked and tested (Closed)
Patch Set: move md_settings_ui_unittest.cc in chrome/test/BUILD.gn Created 3 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"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
14 #include "content/public/browser/web_ui.h" 13 #include "content/public/browser/web_ui.h"
15 #include "content/public/browser/web_ui_message_handler.h" 14 #include "content/public/browser/web_ui_message_handler.h"
16 #include "content/public/common/url_constants.h" 15 #include "content/public/common/url_constants.h"
17 #include "content/public/test/browser_test_utils.h"
18 #include "ui/base/window_open_disposition.h"
19 #include "url/gurl.h" 16 #include "url/gurl.h"
20 17
21 typedef InProcessBrowserTest MdSettingsUITest; 18 typedef InProcessBrowserTest MdSettingsUITest;
22 19
23 using ui_test_utils::NavigateToURL; 20 using ui_test_utils::NavigateToURL;
24 using content::WaitForLoadStop;
25 21
26 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) { 22 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) {
27 NavigateToURL(browser(), GURL(content::kViewSourceScheme + std::string(":") + 23 NavigateToURL(browser(), GURL(content::kViewSourceScheme + std::string(":") +
28 chrome::kChromeUIMdSettingsURL + 24 chrome::kChromeUIMdSettingsURL +
29 std::string("strings.js"))); 25 std::string("strings.js")));
30 } 26 }
31 27
32 // May not complete on memory and Windows debug bots. TODO(dbeam): investigate
33 // and fix. See https://crbug.com/558434, https://crbug.com/620370 and
34 // https://crbug.com/651296.
35 //
36 // Disabled for ASan. See http://crbug.com/727449.
37 #if defined(MEMORY_SANITIZER) || defined(OS_WIN) || defined(OS_CHROMEOS) || \
38 defined(ADDRESS_SANITIZER)
39 #define MAYBE_BackForwardDoesntCrash DISABLED_BackForwardDoesntCrash
40 #else
41 #define MAYBE_BackForwardDoesntCrash BackForwardDoesntCrash
42 #endif
43
44 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, MAYBE_BackForwardDoesntCrash) {
45 NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
46
47 NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
48
49 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
50 WaitForLoadStop(browser()->tab_strip_model()->GetActiveWebContents());
51 }
52
53 // Catch lifetime issues in message handlers. There was previously a problem 28 // Catch lifetime issues in message handlers. There was previously a problem
54 // with PrefMember calling Init again after Destroy. 29 // with PrefMember calling Init again after Destroy.
55 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ToggleJavaScript) { 30 IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ToggleJavaScript) {
56 NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL)); 31 NavigateToURL(browser(), GURL(chrome::kChromeUIMdSettingsURL));
57 32
58 const auto& handlers = *browser() 33 const auto& handlers = *browser()
59 ->tab_strip_model() 34 ->tab_strip_model()
60 ->GetActiveWebContents() 35 ->GetActiveWebContents()
61 ->GetWebUI() 36 ->GetWebUI()
62 ->GetHandlersForTesting(); 37 ->GetHandlersForTesting();
63 38
64 for (const std::unique_ptr<content::WebUIMessageHandler>& handler : 39 for (const std::unique_ptr<content::WebUIMessageHandler>& handler :
65 handlers) { 40 handlers) {
66 handler->AllowJavascriptForTesting(); 41 handler->AllowJavascriptForTesting();
67 handler->DisallowJavascript(); 42 handler->DisallowJavascript();
68 handler->AllowJavascriptForTesting(); 43 handler->AllowJavascriptForTesting();
69 } 44 }
70 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.cc ('k') | chrome/browser/ui/webui/settings/md_settings_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698