OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 22852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22863 SourceURLHelper("function foo() {}\n" | 22863 SourceURLHelper("function foo() {}\n" |
22864 "//# sourceURL=bar19\".js \n" | 22864 "//# sourceURL=bar19\".js \n" |
22865 "//# sourceMappingURL=bar20\".js \n", | 22865 "//# sourceMappingURL=bar20\".js \n", |
22866 NULL, NULL); | 22866 NULL, NULL); |
22867 | 22867 |
22868 // Not too much whitespace. | 22868 // Not too much whitespace. |
22869 SourceURLHelper("function foo() {}\n" | 22869 SourceURLHelper("function foo() {}\n" |
22870 "//# sourceURL= bar21.js \n" | 22870 "//# sourceURL= bar21.js \n" |
22871 "//# sourceMappingURL= bar22.js \n", "bar21.js", "bar22.js"); | 22871 "//# sourceMappingURL= bar22.js \n", "bar21.js", "bar22.js"); |
22872 } | 22872 } |
| 22873 |
| 22874 |
| 22875 TEST(GetOwnPropertyDescriptor) { |
| 22876 LocalContext env; |
| 22877 v8::Isolate* isolate = env->GetIsolate(); |
| 22878 v8::HandleScope scope(isolate); |
| 22879 CompileRun( |
| 22880 "var x = { value : 13};" |
| 22881 "Object.defineProperty(x, 'p0', {value : 12});" |
| 22882 "Object.defineProperty(x, 'p1', {" |
| 22883 " set : function(value) { this.value = value; }," |
| 22884 " get : function() { return this.value; }," |
| 22885 "});"); |
| 22886 Local<Object> x = Local<Object>::Cast(env->Global()->Get(v8_str("x"))); |
| 22887 Local<Value> desc = x->GetOwnPropertyDescriptor(v8_str("no_prop")); |
| 22888 CHECK(desc->IsUndefined()); |
| 22889 desc = x->GetOwnPropertyDescriptor(v8_str("p0")); |
| 22890 CHECK_EQ(v8_num(12), Local<Object>::Cast(desc)->Get(v8_str("value"))); |
| 22891 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
| 22892 Local<Function> set = |
| 22893 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
| 22894 Local<Function> get = |
| 22895 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
| 22896 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
| 22897 Handle<Value> args[] = { v8_num(14) }; |
| 22898 set->Call(x, 1, args); |
| 22899 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
| 22900 } |
OLD | NEW |