diff options
author | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 03:22:42 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-26 03:22:42 +0000 |
commit | 3240e0812ab1a3a7a97f570871c33fd54168fc1b (patch) | |
tree | 71b8d99420779aec73eba978f584f9f544769eac /content/browser | |
parent | 5e22102dd7c9441a6e1cd692803800ebb0042c64 (diff) | |
download | chromium_src-3240e0812ab1a3a7a97f570871c33fd54168fc1b.zip chromium_src-3240e0812ab1a3a7a97f570871c33fd54168fc1b.tar.gz chromium_src-3240e0812ab1a3a7a97f570871c33fd54168fc1b.tar.bz2 |
Distinguish null IDBKey (no value) and invalid IDBKey (value is not valid key)
WebKit change is https://bugs.webkit.org/show_bug.cgi?id=76487
Browser tests are updated and extended to validate null vs. invalid paths. The
IndexedDBKey type is updated to support null in addition to invalid, and key path
parsing failures now yield nulls.
BUG=110956, 111431
TEST=
Review URL: https://chromiumcodereview.appspot.com/9212038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
3 files changed, 89 insertions, 41 deletions
diff --git a/content/browser/in_process_webkit/indexed_db_browsertest.cc b/content/browser/in_process_webkit/indexed_db_browsertest.cc index 4693b3b..09531283 100644 --- a/content/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/content/browser/in_process_webkit/indexed_db_browsertest.cc @@ -60,19 +60,16 @@ class IndexedDBBrowserTest : public InProcessBrowserTest { } }; -// TODO(jsbell): Disabled to land WK76487; http://crbug.com/110956 has fix. -IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DISABLED_CursorTest) { +IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("cursor_test.html")))); } -// TODO(jsbell): Disabled to land WK76487; http://crbug.com/110956 has fix. -IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DISABLED_CursorTestIncognito) { +IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("cursor_test.html"))), true /* incognito */); } -// TODO(jsbell): Disabled to land WK76487; http://crbug.com/110956 has fix. -IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DISABLED_CursorPrefetch) { +IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorPrefetch) { SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("cursor_prefetch.html")))); } diff --git a/content/browser/in_process_webkit/indexed_db_uitest.cc b/content/browser/in_process_webkit/indexed_db_uitest.cc index ee427e5..99750c5 100644 --- a/content/browser/in_process_webkit/indexed_db_uitest.cc +++ b/content/browser/in_process_webkit/indexed_db_uitest.cc @@ -36,7 +36,7 @@ class IndexedDBUILayoutTest : public UILayoutTest { FilePath test_dir_; }; -TEST_F(IndexedDBUILayoutTest, DISABLED_LayoutTests) { +TEST_F(IndexedDBUILayoutTest, LayoutTests) { const int port = kNoHttpPort; InitializeForLayoutTest(test_dir_, FilePath(), port); AddJSTestResources(); diff --git a/content/browser/indexed_db/idbbindingutilities_browsertest.cc b/content/browser/indexed_db/idbbindingutilities_browsertest.cc index 0793e0b..b47645f 100644 --- a/content/browser/indexed_db/idbbindingutilities_browsertest.cc +++ b/content/browser/indexed_db/idbbindingutilities_browsertest.cc @@ -37,28 +37,46 @@ class ScopedShutdownWebKit { }; // Sanity test, check the function call directly outside the sandbox. -// TODO(jsbell): Disabled to land WK76487; http://crbug.com/110956 has fix. -TEST(IDBKeyPathWithoutSandbox, DISABLED_Value) { +TEST(IDBKeyPathWithoutSandbox, Value) { content::WebKitPlatformSupportImpl webkit_platform_support; WebKit::initialize(&webkit_platform_support); ScopedShutdownWebKit shutdown_webkit; - char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; + // {foo: "zoo"} + char16 data_foo_zoo[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; std::vector<WebSerializedScriptValue> serialized_values; serialized_values.push_back( - WebSerializedScriptValue::fromString(string16(data, arraysize(data)))); + WebSerializedScriptValue::fromString(string16(data_foo_zoo, + arraysize(data_foo_zoo)))); + + // {foo: null} + char16 data_foo_null[] = {0x0353, 0x6f66, 0x306f, 0x017b}; + serialized_values.push_back(content::SerializedScriptValue( + false, false, string16(data_foo_null, arraysize(data_foo_null)))); + + // {} + char16 data_object[] = {0x017b}; + serialized_values.push_back(content::SerializedScriptValue( + false, false, string16(data_object, arraysize(data_object)))); + + // null serialized_values.push_back( WebSerializedScriptValue::fromString(string16())); std::vector<WebKit::WebIDBKey> values; - string16 key_path(UTF8ToUTF16("foo")); - bool error = webkit_glue::IDBKeysFromValuesAndKeyPath( + string16 key_path; + bool error; + + key_path = UTF8ToUTF16("foo"); + error = webkit_glue::IDBKeysFromValuesAndKeyPath( serialized_values, key_path, &values); - ASSERT_EQ(size_t(2), values.size()); + ASSERT_EQ(size_t(4), values.size()); ASSERT_EQ(WebKit::WebIDBKey::StringType, values[0].type()); ASSERT_EQ(UTF8ToUTF16("zoo"), values[0].string()); ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[1].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type()); ASSERT_FALSE(error); values.clear(); @@ -66,9 +84,11 @@ TEST(IDBKeyPathWithoutSandbox, DISABLED_Value) { error = webkit_glue::IDBKeysFromValuesAndKeyPath( serialized_values, key_path, &values); - ASSERT_EQ(size_t(2), values.size()); - ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[0].type()); - ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[1].type()); + ASSERT_EQ(size_t(4), values.size()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[0].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[1].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type()); ASSERT_FALSE(error); values.clear(); @@ -77,9 +97,11 @@ TEST(IDBKeyPathWithoutSandbox, DISABLED_Value) { serialized_values, key_path, &values); ASSERT_TRUE(error); - ASSERT_EQ(size_t(2), values.size()); - ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[0].type()); - ASSERT_EQ(WebKit::WebIDBKey::InvalidType, values[1].type()); + ASSERT_EQ(size_t(4), values.size()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[0].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[1].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[2].type()); + ASSERT_EQ(WebKit::WebIDBKey::NullType, values[3].type()); } class IDBKeyPathHelper : public UtilityProcessHost::Client { @@ -270,26 +292,44 @@ class ScopedIDBKeyPathHelper { scoped_refptr<IDBKeyPathHelper> key_path_helper_; }; +// Cases: IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) { ScopedIDBKeyPathHelper scoped_helper; const int kId = 7; std::vector<IndexedDBKey> expected_keys; - IndexedDBKey value; - value.SetString(UTF8ToUTF16("zoo")); - expected_keys.push_back(value); + std::vector<content::SerializedScriptValue> serialized_values; - IndexedDBKey invalid_value; - invalid_value.SetInvalid(); - expected_keys.push_back(invalid_value); + IndexedDBKey string_zoo_key; + string_zoo_key.SetString(UTF8ToUTF16("zoo")); + IndexedDBKey null_key; + null_key.SetNull(); + IndexedDBKey invalid_key; + invalid_key.SetInvalid(); - scoped_helper.SetExpectedKeys(kId, expected_keys, false); + // keypath: "foo", value: {foo: "zoo"}, expected: "zoo" + char16 data_foo_zoo[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; + serialized_values.push_back(content::SerializedScriptValue( + false, false, string16(data_foo_zoo, arraysize(data_foo_zoo)))); + expected_keys.push_back(string_zoo_key); - char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; - std::vector<content::SerializedScriptValue> serialized_values; + // keypath: "foo", value: {foo: null}, expected: invalid + char16 data_foo_null[] = {0x0353, 0x6f66, 0x306f, 0x017b}; serialized_values.push_back(content::SerializedScriptValue( - false, false, string16(data, arraysize(data)))); + false, false, string16(data_foo_null, arraysize(data_foo_null)))); + expected_keys.push_back(invalid_key); + + // keypath: "foo", value: {}, expected: null + char16 data_object[] = {0x017b}; + serialized_values.push_back(content::SerializedScriptValue( + false, false, string16(data_object, arraysize(data_object)))); + expected_keys.push_back(null_key); + + // keypath: "foo", value: null, expected: null serialized_values.push_back( content::SerializedScriptValue(true, false, string16())); + expected_keys.push_back(null_key); + + scoped_helper.SetExpectedKeys(kId, expected_keys, false); scoped_helper.CheckValuesForKeyPath( kId, serialized_values, UTF8ToUTF16("foo")); } @@ -298,19 +338,24 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) { ScopedIDBKeyPathHelper scoped_helper; const int kId = 7; std::vector<IndexedDBKey> expected_keys; - IndexedDBKey invalid_value; - invalid_value.SetInvalid(); - expected_keys.push_back(invalid_value); - expected_keys.push_back(invalid_value); + IndexedDBKey null_value; + null_value.SetNull(); + expected_keys.push_back(null_value); + expected_keys.push_back(null_value); scoped_helper.SetExpectedKeys(kId, expected_keys, false); - char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; std::vector<content::SerializedScriptValue> serialized_values; + // {foo: "zoo", bar: null} + char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, + 0x3072, 0x027b}; serialized_values.push_back(content::SerializedScriptValue( false, false, string16(data, arraysize(data)))); + + // null serialized_values.push_back( content::SerializedScriptValue(true, false, string16())); + scoped_helper.CheckValuesForKeyPath(kId, serialized_values, UTF8ToUTF16("PropertyNotAvailable")); } @@ -319,19 +364,25 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) { ScopedIDBKeyPathHelper scoped_helper; const int kId = 7; std::vector<IndexedDBKey> expected_keys; - IndexedDBKey invalid_value; - invalid_value.SetInvalid(); - expected_keys.push_back(invalid_value); - expected_keys.push_back(invalid_value); + IndexedDBKey null_value; + null_value.SetNull(); + expected_keys.push_back(null_value); + expected_keys.push_back(null_value); scoped_helper.SetExpectedKeys(kId, expected_keys, true); - char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b}; std::vector<content::SerializedScriptValue> serialized_values; + + // {foo: "zoo", bar: null} + char16 data[] = {0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x0353, 0x6162, + 0x3072, 0x027b}; serialized_values.push_back(content::SerializedScriptValue( false, false, string16(data, arraysize(data)))); + + // null serialized_values.push_back( content::SerializedScriptValue(true, false, string16())); + scoped_helper.CheckValuesForKeyPath(kId, serialized_values, UTF8ToUTF16("!+Invalid[KeyPath[[[")); @@ -340,7 +391,7 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) { IndexedDBKey value; value.SetString(UTF8ToUTF16("zoo")); expected_keys.push_back(value); - expected_keys.push_back(invalid_value); + expected_keys.push_back(null_value); scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false); scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values, UTF8ToUTF16("foo")); |