OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // A simple C++ Pepper plugin for exercising deprecated PPAPI interfaces in | 5 // A simple C++ Pepper plugin for exercising deprecated PPAPI interfaces in |
6 // Blink layout tests. | 6 // Blink layout tests. |
7 // | 7 // |
8 // Most layout tests should prefer to use the normal Blink test plugin, with the | 8 // Most layout tests should prefer to use the normal Blink test plugin, with the |
9 // MIME type application/x-blink-test-plugin. For layout tests that absolutely | 9 // MIME type application/x-blink-test-plugin. For layout tests that absolutely |
10 // need to test deprecated synchronous scripting interfaces, this plugin can be | 10 // need to test deprecated synchronous scripting interfaces, this plugin can be |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 base::Bind(&InstanceSO::TestExecuteScript, base::Unretained(this)))); | 130 base::Bind(&InstanceSO::TestExecuteScript, base::Unretained(this)))); |
131 methods_.insert(std::make_pair( | 131 methods_.insert(std::make_pair( |
132 "testGetProperty", | 132 "testGetProperty", |
133 base::Bind(&InstanceSO::TestGetProperty, base::Unretained(this)))); | 133 base::Bind(&InstanceSO::TestGetProperty, base::Unretained(this)))); |
134 methods_.insert(std::make_pair( | 134 methods_.insert(std::make_pair( |
135 "testPassTestObject", | 135 "testPassTestObject", |
136 base::Bind(&InstanceSO::TestPassTestObject, base::Unretained(this)))); | 136 base::Bind(&InstanceSO::TestPassTestObject, base::Unretained(this)))); |
137 properties_.insert(std::make_pair( | 137 properties_.insert(std::make_pair( |
138 "testObject", base::Bind(&InstanceSO::TestObjectAccessor, | 138 "testObject", base::Bind(&InstanceSO::TestObjectAccessor, |
139 base::Unretained(this)))); | 139 base::Unretained(this)))); |
| 140 properties_.insert(std::make_pair( |
| 141 "testGetUndefined", base::Bind(&InstanceSO::TestGetUndefinedAccessor, |
| 142 base::Unretained(this)))); |
140 } | 143 } |
141 ~InstanceSO() override {} | 144 ~InstanceSO() override {} |
142 | 145 |
143 private: | 146 private: |
144 // Requires one argument. The argument is passed through as-is to | 147 // Requires one argument. The argument is passed through as-is to |
145 // pp::InstancePrivate::ExecuteScript(). | 148 // pp::InstancePrivate::ExecuteScript(). |
146 pp::Var TestExecuteScript(const std::vector<pp::Var>& args, | 149 pp::Var TestExecuteScript(const std::vector<pp::Var>& args, |
147 pp::Var* exception) { | 150 pp::Var* exception) { |
148 if (args.size() != 1) { | 151 if (args.size() != 1) { |
149 *exception = pp::Var("testExecuteScript requires one argument"); | 152 *exception = pp::Var("testExecuteScript requires one argument"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 186 } |
184 | 187 |
185 void TestObjectAccessor(bool set, pp::Var* var) { | 188 void TestObjectAccessor(bool set, pp::Var* var) { |
186 if (set) | 189 if (set) |
187 return; | 190 return; |
188 if (test_object_.is_undefined()) | 191 if (test_object_.is_undefined()) |
189 test_object_ = pp::VarPrivate(instance_, new TestObjectSO(instance_)); | 192 test_object_ = pp::VarPrivate(instance_, new TestObjectSO(instance_)); |
190 *var = test_object_; | 193 *var = test_object_; |
191 } | 194 } |
192 | 195 |
| 196 void TestGetUndefinedAccessor(bool set, pp::Var* var) { |
| 197 if (set) |
| 198 return; |
| 199 *var = pp::Var(); |
| 200 } |
| 201 |
193 pp::VarPrivate test_object_; | 202 pp::VarPrivate test_object_; |
194 }; | 203 }; |
195 | 204 |
196 class BlinkDeprecatedTestInstance : public pp::InstancePrivate { | 205 class BlinkDeprecatedTestInstance : public pp::InstancePrivate { |
197 public: | 206 public: |
198 explicit BlinkDeprecatedTestInstance(PP_Instance instance) | 207 explicit BlinkDeprecatedTestInstance(PP_Instance instance) |
199 : pp::InstancePrivate(instance) {} | 208 : pp::InstancePrivate(instance) {} |
200 ~BlinkDeprecatedTestInstance() override { | 209 ~BlinkDeprecatedTestInstance() override { |
201 LogMessage("%s", "Destroying"); | 210 LogMessage("%s", "Destroying"); |
202 } | 211 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 250 |
242 } // namespace | 251 } // namespace |
243 | 252 |
244 namespace pp { | 253 namespace pp { |
245 | 254 |
246 Module* CreateModule() { | 255 Module* CreateModule() { |
247 return new BlinkDeprecatedTestModule(); | 256 return new BlinkDeprecatedTestModule(); |
248 } | 257 } |
249 | 258 |
250 } // namespace pp | 259 } // namespace pp |
OLD | NEW |