| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 296 |
| 297 { | 297 { |
| 298 const char kBinarySpec[] = "{ 'type': 'binary' }"; | 298 const char kBinarySpec[] = "{ 'type': 'binary' }"; |
| 299 ArgumentSpec spec(*ValueFromString(kBinarySpec)); | 299 ArgumentSpec spec(*ValueFromString(kBinarySpec)); |
| 300 // Simple case: empty ArrayBuffer -> empty BinaryValue. | 300 // Simple case: empty ArrayBuffer -> empty BinaryValue. |
| 301 ExpectSuccess(spec, "(new ArrayBuffer())", | 301 ExpectSuccess(spec, "(new ArrayBuffer())", |
| 302 base::Value(base::Value::Type::BINARY)); | 302 base::Value(base::Value::Type::BINARY)); |
| 303 { | 303 { |
| 304 // A non-empty (but zero-filled) ArrayBufferView. | 304 // A non-empty (but zero-filled) ArrayBufferView. |
| 305 const char kBuffer[] = {0, 0, 0, 0}; | 305 const char kBuffer[] = {0, 0, 0, 0}; |
| 306 std::unique_ptr<base::BinaryValue> expected_value = | 306 std::unique_ptr<base::Value> expected_value = |
| 307 base::BinaryValue::CreateWithCopiedBuffer(kBuffer, | 307 base::Value::CreateWithCopiedBuffer(kBuffer, arraysize(kBuffer)); |
| 308 arraysize(kBuffer)); | |
| 309 ASSERT_TRUE(expected_value); | 308 ASSERT_TRUE(expected_value); |
| 310 ExpectSuccessWithNoConversion(spec, "(new Int32Array(2))"); | 309 ExpectSuccessWithNoConversion(spec, "(new Int32Array(2))"); |
| 311 } | 310 } |
| 312 { | 311 { |
| 313 // Actual data. | 312 // Actual data. |
| 314 const char kBuffer[] = {'p', 'i', 'n', 'g'}; | 313 const char kBuffer[] = {'p', 'i', 'n', 'g'}; |
| 315 std::unique_ptr<base::BinaryValue> expected_value = | 314 std::unique_ptr<base::Value> expected_value = |
| 316 base::BinaryValue::CreateWithCopiedBuffer(kBuffer, | 315 base::Value::CreateWithCopiedBuffer(kBuffer, arraysize(kBuffer)); |
| 317 arraysize(kBuffer)); | |
| 318 ASSERT_TRUE(expected_value); | 316 ASSERT_TRUE(expected_value); |
| 319 ExpectSuccess(spec, | 317 ExpectSuccess(spec, |
| 320 "var b = new ArrayBuffer(4);\n" | 318 "var b = new ArrayBuffer(4);\n" |
| 321 "var v = new Uint8Array(b);\n" | 319 "var v = new Uint8Array(b);\n" |
| 322 "var s = 'ping';\n" | 320 "var s = 'ping';\n" |
| 323 "for (var i = 0; i < s.length; ++i)\n" | 321 "for (var i = 0; i < s.length; ++i)\n" |
| 324 " v[i] = s.charCodeAt(i);\n" | 322 " v[i] = s.charCodeAt(i);\n" |
| 325 "b;", | 323 "b;", |
| 326 *expected_value); | 324 *expected_value); |
| 327 } | 325 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 ExpectFailure(spec, "({})"); | 592 ExpectFailure(spec, "({})"); |
| 595 ExpectFailure(spec, | 593 ExpectFailure(spec, |
| 596 "(function() {\n" | 594 "(function() {\n" |
| 597 " function otherClass() {}\n" | 595 " function otherClass() {}\n" |
| 598 " return new otherClass();\n" | 596 " return new otherClass();\n" |
| 599 "})()"); | 597 "})()"); |
| 600 } | 598 } |
| 601 } | 599 } |
| 602 | 600 |
| 603 } // namespace extensions | 601 } // namespace extensions |
| OLD | NEW |