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

Side by Side Diff: chrome/browser/ui/webui/devtools_ui_unittest.cc

Issue 2403633002: [DevTools] Move sanitize url to devtools_ui.cc. (Closed)
Patch Set: disable test on android and ios - there is no devtools_ui Created 4 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
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/devtools_ui.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 class DevToolsUITest : public testing::Test {
9 };
10
11 TEST_F(DevToolsUITest, SanitizeFrontendURL) {
12 std::vector<std::pair<std::string, std::string>> tests = {
13 {"random-string",
14 "chrome-devtools://devtools/"},
15 {"http://valid.url/but/wrong",
16 "chrome-devtools://devtools/but/wrong"},
17 {"chrome-devtools://wrong-domain/",
18 "chrome-devtools://devtools/"},
19 {"chrome-devtools://devtools/bundled/devtools.html",
20 "chrome-devtools://devtools/bundled/devtools.html"},
21 {"chrome-devtools://devtools:1234/bundled/devtools.html#hash",
22 "chrome-devtools://devtools/bundled/devtools.html"},
23 {"chrome-devtools://devtools/some/random/path",
24 "chrome-devtools://devtools/some/random/path"},
25 {"chrome-devtools://devtools/bundled/devtools.html?experiments=true",
26 "chrome-devtools://devtools/bundled/devtools.html?experiments=true"},
27 {"chrome-devtools://devtools/bundled/devtools.html"
28 "?some-flag=flag&v8only=true&experiments=false&debugFrontend=a"
29 "&another-flag=another-flag&can_dock=false&isSharedWorker=notreally"
30 "&remoteFrontend=sure",
31 "chrome-devtools://devtools/bundled/devtools.html"
32 "?v8only=true&experiments=true&debugFrontend=true"
33 "&can_dock=true&isSharedWorker=true&remoteFrontend=true"},
34 {"chrome-devtools://devtools/?ws=any-value-is-fine",
35 "chrome-devtools://devtools/?ws=any-value-is-fine"},
36 {"chrome-devtools://devtools/"
37 "?service-backend=ws://localhost:9222/services",
38 "chrome-devtools://devtools/"
39 "?service-backend=ws://localhost:9222/services"},
40 {"chrome-devtools://devtools/?dockSide=undocked",
41 "chrome-devtools://devtools/?dockSide=undocked"},
42 {"chrome-devtools://devtools/?dockSide=dock-to-bottom",
43 "chrome-devtools://devtools/"},
44 {"chrome-devtools://devtools/?dockSide=bottom",
45 "chrome-devtools://devtools/"},
46 {"chrome-devtools://devtools/?remoteBase="
47 "http://example.com:1234/remote-base#hash",
48 "chrome-devtools://devtools/?remoteBase="
49 "https://chrome-devtools-frontend.appspot.com/"
50 "serve_file//"},
51 {"chrome-devtools://devtools/?ws=1%26evil%3dtrue",
52 "chrome-devtools://devtools/?ws=1%26evil%3dtrue"},
53 {"chrome-devtools://devtools/?remoteBase="
54 "https://chrome-devtools-frontend.appspot.com/some/path/"
55 "@123719741873/more/path.html",
56 "chrome-devtools://devtools/?remoteBase="
57 "https://chrome-devtools-frontend.appspot.com/serve_file/path/"},
58 {"chrome-devtools://devtools/?remoteBase="
59 "https://chrome-devtools-frontend.appspot.com/serve_file/"
60 "@123719741873/inspector.html%3FdebugFrontend%3Dfalse",
61 "chrome-devtools://devtools/?remoteBase="
62 "https://chrome-devtools-frontend.appspot.com/serve_file/"
63 "@123719741873/"},
64 {"chrome-devtools://devtools/bundled/inspector.html?"
65 "&remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/"
66 "@b4907cc5d602ff470740b2eb6344b517edecb7b9/&can_dock=true",
67 "chrome-devtools://devtools/bundled/inspector.html?"
68 "remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/"
69 "@b4907cc5d602ff470740b2eb6344b517edecb7b9/&can_dock=true"},
70 {"chrome-devtools://devtools/?remoteFrontendUrl="
71 "https://chrome-devtools-frontend.appspot.com/serve_rev/"
72 "@12345/inspector.html%3FdebugFrontend%3Dfalse",
73 "chrome-devtools://devtools/?remoteFrontendUrl="
74 "https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
75 "%2F%4012345%2Finspector.html%3FdebugFrontend%3Dtrue"},
76 {"chrome-devtools://devtools/?remoteFrontendUrl="
77 "https://chrome-devtools-frontend.appspot.com/serve_rev/"
78 "@12345/inspector.html%22></iframe>something",
79 "chrome-devtools://devtools/?remoteFrontendUrl="
80 "https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
81 "%2F%4012345%2Finspector.html"},
82 {"chrome-devtools://devtools/?remoteFrontendUrl="
83 "http://domain:1234/path/rev/a/filename.html%3Fparam%3Dvalue#hash",
84 "chrome-devtools://devtools/?remoteFrontendUrl="
85 "https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
86 "%2Frev%2Finspector.html"},
87 {"chrome-devtools://devtools/?experiments=whatever&remoteFrontendUrl="
88 "https://chrome-devtools-frontend.appspot.com/serve_rev/"
89 "@12345/devtools.html%3Fws%3Danyvalue%26experiments%3Dlikely"
90 "&unencoded=value&debugFrontend=true",
91 "chrome-devtools://devtools/?experiments=true&remoteFrontendUrl="
92 "https%3A%2F%2Fchrome-devtools-frontend.appspot.com%2Fserve_rev"
93 "%2F%4012345%2Fdevtools.html%3Fws%3Danyvalue%26experiments%3Dtrue"
94 "&debugFrontend=true"},
95 };
96
97 for (const auto& pair : tests) {
98 GURL url = GURL(pair.first);
99 url = DevToolsUI::SanitizeFrontendURL(url);
100 EXPECT_EQ(pair.second, url.spec());
101 }
102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698