OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "extensions/renderer/api_binding_test_util.h" | 7 #include "extensions/renderer/api_binding_test_util.h" |
8 #include "extensions/renderer/api_type_reference_map.h" | 8 #include "extensions/renderer/api_type_reference_map.h" |
9 #include "extensions/renderer/argument_spec.h" | 9 #include "extensions/renderer/argument_spec.h" |
10 #include "gin/converter.h" | 10 #include "gin/converter.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 ExpectSuccessWithNoConversion(spec, "(function(a, b) { a(); b(); })"); | 255 ExpectSuccessWithNoConversion(spec, "(function(a, b) { a(); b(); })"); |
256 ExpectFailureWithNoConversion(spec, "({a: function() {}})"); | 256 ExpectFailureWithNoConversion(spec, "({a: function() {}})"); |
257 ExpectFailureWithNoConversion(spec, "([function() {}])"); | 257 ExpectFailureWithNoConversion(spec, "([function() {}])"); |
258 ExpectFailureWithNoConversion(spec, "1"); | 258 ExpectFailureWithNoConversion(spec, "1"); |
259 } | 259 } |
260 | 260 |
261 { | 261 { |
262 const char kBinarySpec[] = "{ 'type': 'binary' }"; | 262 const char kBinarySpec[] = "{ 'type': 'binary' }"; |
263 ArgumentSpec spec(*ValueFromString(kBinarySpec)); | 263 ArgumentSpec spec(*ValueFromString(kBinarySpec)); |
264 // Simple case: empty ArrayBuffer -> empty BinaryValue. | 264 // Simple case: empty ArrayBuffer -> empty BinaryValue. |
265 ExpectSuccess(spec, "(new ArrayBuffer())", base::BinaryValue()); | 265 ExpectSuccess(spec, "(new ArrayBuffer())", |
| 266 base::Value(base::Value::Type::BINARY)); |
266 { | 267 { |
267 // A non-empty (but zero-filled) ArrayBufferView. | 268 // A non-empty (but zero-filled) ArrayBufferView. |
268 const char kBuffer[] = {0, 0, 0, 0}; | 269 const char kBuffer[] = {0, 0, 0, 0}; |
269 std::unique_ptr<base::BinaryValue> expected_value = | 270 std::unique_ptr<base::BinaryValue> expected_value = |
270 base::BinaryValue::CreateWithCopiedBuffer(kBuffer, | 271 base::BinaryValue::CreateWithCopiedBuffer(kBuffer, |
271 arraysize(kBuffer)); | 272 arraysize(kBuffer)); |
272 ASSERT_TRUE(expected_value); | 273 ASSERT_TRUE(expected_value); |
273 ExpectSuccessWithNoConversion(spec, "(new Int32Array(2))"); | 274 ExpectSuccessWithNoConversion(spec, "(new Int32Array(2))"); |
274 } | 275 } |
275 { | 276 { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 " 'additionalProperties': {'type': 'string'}" | 498 " 'additionalProperties': {'type': 'string'}" |
498 "}"; | 499 "}"; |
499 ArgumentSpec spec(*ValueFromString(kTypedAdditionalProperties)); | 500 ArgumentSpec spec(*ValueFromString(kTypedAdditionalProperties)); |
500 ExpectSuccess(spec, "({prop1: 'alpha', prop2: 'beta', prop3: 'gamma'})", | 501 ExpectSuccess(spec, "({prop1: 'alpha', prop2: 'beta', prop3: 'gamma'})", |
501 "{'prop1':'alpha','prop2':'beta','prop3':'gamma'}"); | 502 "{'prop1':'alpha','prop2':'beta','prop3':'gamma'}"); |
502 ExpectFailure(spec, "({prop1: 'alpha', prop2: 42})"); | 503 ExpectFailure(spec, "({prop1: 'alpha', prop2: 42})"); |
503 } | 504 } |
504 } | 505 } |
505 | 506 |
506 } // namespace extensions | 507 } // namespace extensions |
OLD | NEW |