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

Side by Side Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 2596613002: Fix use-after-scope issues with incorrect usage of ManifestParser. (Closed)
Patch Set: Created 4 years 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 | « content/renderer/manifest/manifest_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 DISALLOW_COPY_AND_ASSIGN(ManifestParserTest); 64 DISALLOW_COPY_AND_ASSIGN(ManifestParserTest);
65 }; 65 };
66 66
67 const GURL ManifestParserTest::default_document_url( 67 const GURL ManifestParserTest::default_document_url(
68 "http://foo.com/index.html"); 68 "http://foo.com/index.html");
69 const GURL ManifestParserTest::default_manifest_url( 69 const GURL ManifestParserTest::default_manifest_url(
70 "http://foo.com/manifest.json"); 70 "http://foo.com/manifest.json");
71 71
72 TEST_F(ManifestParserTest, CrashTest) { 72 TEST_F(ManifestParserTest, CrashTest) {
73 // Passing temporary variables should not crash. 73 // Passing temporary variables should not crash.
74 ManifestParser parser("{\"start_url\": \"/\"}", 74 const base::StringPiece json = "{\"start_url\": \"/\"}";
75 GURL("http://example.com"), 75 GURL url("http://example.com");
76 GURL("http://example.com")); 76 ManifestParser parser(json, url, url);
77 parser.Parse(); 77 parser.Parse();
78 std::vector<ManifestDebugInfo::Error> errors; 78 std::vector<ManifestDebugInfo::Error> errors;
79 parser.TakeErrors(&errors); 79 parser.TakeErrors(&errors);
80 80
81 // .Parse() should have been call without crashing and succeeded. 81 // .Parse() should have been call without crashing and succeeded.
82 EXPECT_EQ(0u, errors.size()); 82 EXPECT_EQ(0u, errors.size());
83 EXPECT_FALSE(parser.manifest().IsEmpty()); 83 EXPECT_FALSE(parser.manifest().IsEmpty());
84 } 84 }
85 85
86 TEST_F(ManifestParserTest, EmptyStringNull) { 86 TEST_F(ManifestParserTest, EmptyStringNull) {
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 { 1414 {
1415 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); 1415 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }");
1416 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); 1416 EXPECT_TRUE(manifest.gcm_sender_id.is_null());
1417 EXPECT_EQ(1u, GetErrorCount()); 1417 EXPECT_EQ(1u, GetErrorCount());
1418 EXPECT_EQ("property 'gcm_sender_id' ignored, type string expected.", 1418 EXPECT_EQ("property 'gcm_sender_id' ignored, type string expected.",
1419 errors()[0]); 1419 errors()[0]);
1420 } 1420 }
1421 } 1421 }
1422 1422
1423 } // namespace content 1423 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698