| Index: ios/web/web_state/ui/web_view_js_utils_unittest.mm
|
| diff --git a/ios/web/web_state/ui/web_view_js_utils_unittest.mm b/ios/web/web_state/ui/web_view_js_utils_unittest.mm
|
| index cf4b440c9ab4a4cf39eb229affc4802323ef7cb8..beb48b689d5e232b5624abd7271d5a11c855afde 100644
|
| --- a/ios/web/web_state/ui/web_view_js_utils_unittest.mm
|
| +++ b/ios/web/web_state/ui/web_view_js_utils_unittest.mm
|
| @@ -100,6 +100,32 @@ TEST_F(WebViewJsUtilsTest, ValueResultFromNullWKResult) {
|
| EXPECT_EQ(base::Value::TYPE_NULL, value->GetType());
|
| }
|
|
|
| +// Tests that ValueResultFromWKResult converts NSDictionaries to properly
|
| +// initialized base::DictionaryValue.
|
| +TEST_F(WebViewJsUtilsTest, ValueResultFromDictionaryWKResult) {
|
| + NSDictionary* testDictionary =
|
| + @{ @"Key1" : @"Value1",
|
| + @"Key2" : @{@"Key3" : @42} };
|
| +
|
| + std::unique_ptr<base::Value> value(
|
| + web::ValueResultFromWKResult(testDictionary));
|
| + base::DictionaryValue* dictionary = nullptr;
|
| + value->GetAsDictionary(&dictionary);
|
| + EXPECT_NE(nullptr, dictionary);
|
| +
|
| + std::string value1;
|
| + dictionary->GetString("Key1", &value1);
|
| + EXPECT_EQ("Value1", value1);
|
| +
|
| + base::DictionaryValue const* innerDictionary = nullptr;
|
| + dictionary->GetDictionary("Key2", &innerDictionary);
|
| + EXPECT_NE(nullptr, innerDictionary);
|
| +
|
| + double value3;
|
| + innerDictionary->GetDouble("Key3", &value3);
|
| + EXPECT_EQ(42, value3);
|
| +}
|
| +
|
| // Tests that a script with undefined result correctly evaluates to string.
|
| TEST_F(WebViewJsUtilsTest, UndefinedEvaluation) {
|
| EXPECT_NSEQ(@"", EvaluateJavaScript(@"{}"));
|
|
|