diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 03:25:06 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 03:25:06 +0000 |
commit | 8ad0e6bea30cbef719b531dfaa7b4009581ee23e (patch) | |
tree | 1e974ce095f622a8cd9c4d1a56e7e70766fc0e52 /webkit | |
parent | c25bb740b849135b1316bcbb0c30a13d8dda34a2 (diff) | |
download | chromium_src-8ad0e6bea30cbef719b531dfaa7b4009581ee23e.zip chromium_src-8ad0e6bea30cbef719b531dfaa7b4009581ee23e.tar.gz chromium_src-8ad0e6bea30cbef719b531dfaa7b4009581ee23e.tar.bz2 |
We need this work-around for file:/// URIs as
createFromDatabaseIdentifier() returns empty origin urls for them.
Review URL: http://codereview.chromium.org/7053007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/database/database_util.cc | 8 | ||||
-rw-r--r-- | webkit/database/database_util_unittest.cc | 14 |
2 files changed, 19 insertions, 3 deletions
diff --git a/webkit/database/database_util.cc b/webkit/database/database_util.cc index d86a8c2..184e495 100644 --- a/webkit/database/database_util.cc +++ b/webkit/database/database_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -77,7 +77,11 @@ string16 DatabaseUtil::GetOriginIdentifier(const GURL& url) { GURL DatabaseUtil::GetOriginFromIdentifier(const string16& origin_identifier) { GURL origin(WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( origin_identifier).toString()); - DCHECK(origin == origin.GetOrigin()); + // We need this work-around for file:/// URIs as + // createFromDatabaseIdentifier returns empty origin url for them. + if (origin.spec().empty() && + origin_identifier.find(ASCIIToUTF16("file__")) == 0) + return GURL("file:///"); return origin; } diff --git a/webkit/database/database_util_unittest.cc b/webkit/database/database_util_unittest.cc index f6e3e2c..18c7014 100644 --- a/webkit/database/database_util_unittest.cc +++ b/webkit/database/database_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,6 +26,11 @@ static void TestVfsFilePath(bool expected_result, EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix); } +static GURL ToAndFromOriginIdentifier(const GURL origin_url) { + string16 id = DatabaseUtil::GetOriginIdentifier(origin_url); + return DatabaseUtil::GetOriginFromIdentifier(id); +} + namespace webkit_database { // Test DatabaseUtil::CrackVfsFilePath on various inputs. @@ -42,4 +47,11 @@ TEST(DatabaseUtilTest, CrackVfsFilePathTest) { TestVfsFilePath(false, "/db_name#suffix"); } +TEST(DatabaseUtilTest, OriginIdentifiers) { + const GURL kFileOrigin(GURL("file:///").GetOrigin()); + const GURL kHttpOrigin(GURL("http://bar/").GetOrigin()); + EXPECT_EQ(kFileOrigin, ToAndFromOriginIdentifier(kFileOrigin)); + EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin)); +} + } // namespace webkit_database |