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

Side by Side Diff: chrome/browser/android/webapk/webapk_web_manifest_checker_unittest.cc

Issue 2248293002: Do not install WebAPKs with web manifests with invalid URL components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'webapk_updater_non_installable' into webapk_installable_checker Created 4 years, 3 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
(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/android/webapk/webapk_web_manifest_checker.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/common/manifest.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/platform/WebDisplayMode.h"
11 #include "url/gurl.h"
12
13 namespace {
14
15 base::NullableString16 ToNullableUTF16(const std::string& str) {
16 return base::NullableString16(base::UTF8ToUTF16(str), false);
17 }
18
19 content::Manifest GetValidManifest() {
20 content::Manifest manifest;
21 manifest.name = ToNullableUTF16("foo");
22 manifest.short_name = ToNullableUTF16("bar");
23 manifest.start_url = GURL("http://example.com");
24 manifest.display = blink::WebDisplayModeStandalone;
25
26 content::Manifest::Icon icon;
27 icon.type = ToNullableUTF16("image/png");
28 icon.sizes.push_back(gfx::Size(144, 144));
29 manifest.icons.push_back(icon);
30
31 return manifest;
32 }
33
34 } // anonymous namespace
35
36 TEST(WebApkWebManifestCheckerTest, Compatible) {
37 content::Manifest manifest = GetValidManifest();
38 EXPECT_TRUE(AreWebManifestUrlsWebApkCompatible(manifest));
39 }
40
41 TEST(WebApkWebManifestCheckerTest, CompatibleURLHasNoPassword) {
42 const GURL kUrlWithPassword("http://answer:42@life/universe/and/everything");
43
44 content::Manifest manifest = GetValidManifest();
45 manifest.start_url = kUrlWithPassword;
46 EXPECT_FALSE(AreWebManifestUrlsWebApkCompatible(manifest));
47
48 manifest = GetValidManifest();
49 manifest.icons[0].src = kUrlWithPassword;
50 EXPECT_FALSE(AreWebManifestUrlsWebApkCompatible(manifest));
51 }
52
53 TEST(WebApkWebManifestCheckerTest, CompatibleURLHasNoPort) {
dominickn 2016/08/24 15:36:54 Minor nit - you should test manifest.scope as well
54 const GURL kUrlWithPort("http://www.google.com:42");
55
56 content::Manifest manifest = GetValidManifest();
57 manifest.start_url = kUrlWithPort;
58 EXPECT_FALSE(AreWebManifestUrlsWebApkCompatible(manifest));
59
60 manifest = GetValidManifest();
61 manifest.icons[0].src = kUrlWithPort;
62 EXPECT_FALSE(AreWebManifestUrlsWebApkCompatible(manifest));
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698