Chromium Code Reviews| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "extensions/renderer/bindings/api_binding.h" | 10 #include "extensions/renderer/bindings/api_binding.h" |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 TEST_F(APIBindingUnittest, TestProperties) { | 599 TEST_F(APIBindingUnittest, TestProperties) { |
| 600 SetProperties( | 600 SetProperties( |
| 601 "{" | 601 "{" |
| 602 " 'prop1': { 'value': 17, 'type': 'integer' }," | 602 " 'prop1': { 'value': 17, 'type': 'integer' }," |
| 603 " 'prop2': {" | 603 " 'prop2': {" |
| 604 " 'type': 'object'," | 604 " 'type': 'object'," |
| 605 " 'properties': {" | 605 " 'properties': {" |
| 606 " 'subprop1': { 'value': 'some value', 'type': 'string' }," | 606 " 'subprop1': { 'value': 'some value', 'type': 'string' }," |
| 607 " 'subprop2': { 'value': true, 'type': 'boolean' }" | 607 " 'subprop2': { 'value': true, 'type': 'boolean' }" |
| 608 " }" | 608 " }" |
| 609 " }," | |
| 610 " 'linuxOnly': {" | |
| 611 " 'value': 'linux'," | |
| 612 " 'type': 'string'," | |
| 613 " 'platforms': ['linux']" | |
| 614 " }," | |
| 615 " 'nonLinuxOnly': {" | |
| 616 " 'value': 'nonlinux'," | |
| 617 " 'type': 'string'," | |
| 618 " 'platforms': ['win', 'mac', 'chromeos']" | |
| 609 " }" | 619 " }" |
| 610 "}"); | 620 "}"); |
| 611 InitializeBinding(); | 621 InitializeBinding(); |
| 612 | 622 |
| 613 v8::HandleScope handle_scope(isolate()); | 623 v8::HandleScope handle_scope(isolate()); |
| 614 v8::Local<v8::Context> context = MainContext(); | 624 v8::Local<v8::Context> context = MainContext(); |
| 615 v8::Local<v8::Object> binding_object = binding()->CreateInstance(context); | 625 v8::Local<v8::Object> binding_object = binding()->CreateInstance(context); |
| 616 EXPECT_EQ("17", | 626 EXPECT_EQ("17", |
| 617 GetStringPropertyFromObject(binding_object, context, "prop1")); | 627 GetStringPropertyFromObject(binding_object, context, "prop1")); |
| 618 EXPECT_EQ(R"({"subprop1":"some value","subprop2":true})", | 628 EXPECT_EQ(R"({"subprop1":"some value","subprop2":true})", |
| 619 GetStringPropertyFromObject(binding_object, context, "prop2")); | 629 GetStringPropertyFromObject(binding_object, context, "prop2")); |
| 630 | |
| 631 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 632 EXPECT_EQ("\"linux\"", | |
| 633 GetStringPropertyFromObject(binding_object, context, "linuxOnly")); | |
| 634 EXPECT_EQ("undefined", GetStringPropertyFromObject(binding_object, context, | |
| 635 "nonLinuxOnly")); | |
| 636 #else | |
| 637 EXPECT_EQ("undefined", | |
| 638 GetStringPropertyFromObject(binding_object, context, "linuxOnly")); | |
| 639 EXPECT_EQ("nonlinux", GetStringPropertyFromObject(binding_object, context, | |
|
jbroman
2017/06/29 15:24:21
As the trybots are already indicating, this should
Devlin
2017/06/29 21:00:51
Yep, already done in PS4 :)
| |
| 640 "nonLinuxOnly")); | |
| 641 #endif | |
| 620 } | 642 } |
| 621 | 643 |
| 622 TEST_F(APIBindingUnittest, TestRefProperties) { | 644 TEST_F(APIBindingUnittest, TestRefProperties) { |
| 623 SetProperties( | 645 SetProperties( |
| 624 "{" | 646 "{" |
| 625 " 'alpha': {" | 647 " 'alpha': {" |
| 626 " '$ref': 'AlphaRef'," | 648 " '$ref': 'AlphaRef'," |
| 627 " 'value': ['a']" | 649 " 'value': ['a']" |
| 628 " }," | 650 " }," |
| 629 " 'beta': {" | 651 " 'beta': {" |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1273 | 1295 |
| 1274 // The extra property should be present on the binding object. | 1296 // The extra property should be present on the binding object. |
| 1275 EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context, | 1297 EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context, |
| 1276 "hookedProperty")); | 1298 "hookedProperty")); |
| 1277 // Sanity check: other values should still be there. | 1299 // Sanity check: other values should still be there. |
| 1278 EXPECT_EQ("function", | 1300 EXPECT_EQ("function", |
| 1279 GetStringPropertyFromObject(binding_object, context, "oneString")); | 1301 GetStringPropertyFromObject(binding_object, context, "oneString")); |
| 1280 } | 1302 } |
| 1281 | 1303 |
| 1282 } // namespace extensions | 1304 } // namespace extensions |
| OLD | NEW |