| OLD | NEW | 
|---|
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" | 
| 6 #include "testing/js_embedder_test.h" | 6 #include "testing/js_embedder_test.h" | 
| 7 | 7 | 
| 8 namespace { | 8 namespace { | 
| 9 | 9 | 
| 10 const double kExpected0 = 6.0; | 10 const double kExpected0 = 6.0; | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29     v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); | 29     v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); | 
| 30     EXPECT_TRUE(fred->IsNumber()); | 30     EXPECT_TRUE(fred->IsNumber()); | 
| 31     EXPECT_EQ(expected, fred->ToNumber(isolate()->GetCurrentContext()) | 31     EXPECT_EQ(expected, fred->ToNumber(isolate()->GetCurrentContext()) | 
| 32                             .ToLocalChecked() | 32                             .ToLocalChecked() | 
| 33                             ->Value()); | 33                             ->Value()); | 
| 34   } | 34   } | 
| 35 }; | 35 }; | 
| 36 | 36 | 
| 37 TEST_F(FXJSV8EmbedderTest, Getters) { | 37 TEST_F(FXJSV8EmbedderTest, Getters) { | 
| 38   v8::Isolate::Scope isolate_scope(isolate()); | 38   v8::Isolate::Scope isolate_scope(isolate()); | 
| 39 #ifdef PDF_ENABLE_XFA |  | 
| 40   v8::Locker locker(isolate()); |  | 
| 41 #endif  // PDF_ENABLE_XFA |  | 
| 42   v8::HandleScope handle_scope(isolate()); | 39   v8::HandleScope handle_scope(isolate()); | 
| 43   v8::Context::Scope context_scope(GetV8Context()); | 40   v8::Context::Scope context_scope(GetV8Context()); | 
| 44 | 41 | 
| 45   ExecuteInCurrentContext(kScript1); | 42   ExecuteInCurrentContext(kScript1); | 
| 46   CheckAssignmentInCurrentContext(kExpected1); | 43   CheckAssignmentInCurrentContext(kExpected1); | 
| 47 } | 44 } | 
| 48 | 45 | 
| 49 TEST_F(FXJSV8EmbedderTest, MultipleRutimes) { | 46 TEST_F(FXJSV8EmbedderTest, MultipleRutimes) { | 
| 50   v8::Isolate::Scope isolate_scope(isolate()); | 47   v8::Isolate::Scope isolate_scope(isolate()); | 
| 51 #ifdef PDF_ENABLE_XFA |  | 
| 52   v8::Locker locker(isolate()); |  | 
| 53 #endif  // PDF_ENABLE_XFA |  | 
| 54   v8::HandleScope handle_scope(isolate()); | 48   v8::HandleScope handle_scope(isolate()); | 
| 55 | 49 | 
| 56   v8::Global<v8::Context> global_context1; | 50   v8::Global<v8::Context> global_context1; | 
| 57   std::vector<v8::Global<v8::Object>*> static_objects1; | 51   std::vector<v8::Global<v8::Object>*> static_objects1; | 
| 58   FXJS_InitializeRuntime(isolate(), nullptr, &global_context1, | 52   FXJS_InitializeRuntime(isolate(), nullptr, &global_context1, | 
| 59                          &static_objects1); | 53                          &static_objects1); | 
| 60 | 54 | 
| 61   v8::Global<v8::Context> global_context2; | 55   v8::Global<v8::Context> global_context2; | 
| 62   std::vector<v8::Global<v8::Object>*> static_objects2; | 56   std::vector<v8::Global<v8::Object>*> static_objects2; | 
| 63   FXJS_InitializeRuntime(isolate(), nullptr, &global_context2, | 57   FXJS_InitializeRuntime(isolate(), nullptr, &global_context2, | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 80     v8::Local<v8::Context> context2 = | 74     v8::Local<v8::Context> context2 = | 
| 81         v8::Local<v8::Context>::New(isolate(), global_context2); | 75         v8::Local<v8::Context>::New(isolate(), global_context2); | 
| 82     v8::Context::Scope context_scope(context2); | 76     v8::Context::Scope context_scope(context2); | 
| 83     ExecuteInCurrentContext(kScript2); | 77     ExecuteInCurrentContext(kScript2); | 
| 84     CheckAssignmentInCurrentContext(kExpected2); | 78     CheckAssignmentInCurrentContext(kExpected2); | 
| 85   } | 79   } | 
| 86   FXJS_ReleaseRuntime(isolate(), &global_context2, &static_objects2); | 80   FXJS_ReleaseRuntime(isolate(), &global_context2, &static_objects2); | 
| 87 | 81 | 
| 88   CheckAssignmentInCurrentContext(kExpected0); | 82   CheckAssignmentInCurrentContext(kExpected0); | 
| 89 } | 83 } | 
| OLD | NEW | 
|---|