Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp

Issue 1388023003: Merge to XFA: Make the vast majority of JS headers private to src/javascript. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/util.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../../third_party/base/nonstd_unique_ptr.h"
5 #include "../../../core/include/fpdfapi/fpdf_parser.h" 6 #include "../../../core/include/fpdfapi/fpdf_parser.h"
6 #include "../../../testing/embedder_test.h" 7 #include "../../../testing/embedder_test.h"
7 #include "../../include/fsdk_mgr.h"
8 #include "../../include/javascript/JS_Runtime.h"
9 #include "../../include/jsapi/fxjs_v8.h" 8 #include "../../include/jsapi/fxjs_v8.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 namespace { 11 namespace {
13 12
14 const wchar_t kScript[] = L"fred = 7"; 13 const wchar_t kScript[] = L"fred = 7";
15 14
16 } // namespace 15 } // namespace
17 16
18 class FXJSV8Embeddertest : public EmbedderTest { 17 class FXJSV8Embeddertest : public EmbedderTest {
(...skipping 24 matching lines...) Expand all
43 } 42 }
44 43
45 v8::Isolate* isolate() const { return m_pIsolate; } 44 v8::Isolate* isolate() const { return m_pIsolate; }
46 v8::Local<v8::Context> GetV8Context() { 45 v8::Local<v8::Context> GetV8Context() {
47 return v8::Local<v8::Context>::New(m_pIsolate, m_pPersistentContext); 46 return v8::Local<v8::Context>::New(m_pIsolate, m_pPersistentContext);
48 } 47 }
49 48
50 private: 49 private:
51 v8::Isolate* m_pIsolate; 50 v8::Isolate* m_pIsolate;
52 v8::Global<v8::Context> m_pPersistentContext; 51 v8::Global<v8::Context> m_pPersistentContext;
53 nonstd::unique_ptr<v8::ArrayBuffer::Allocator> m_pAllocator; 52 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pAllocator;
54 }; 53 };
55 54
56 TEST_F(FXJSV8Embeddertest, Getters) { 55 TEST_F(FXJSV8Embeddertest, Getters) {
57 v8::Isolate::Scope isolate_scope(isolate()); 56 v8::Isolate::Scope isolate_scope(isolate());
58 v8::Locker locker(isolate()); 57 v8::Locker locker(isolate());
59 v8::HandleScope handle_scope(isolate()); 58 v8::HandleScope handle_scope(isolate());
60 v8::Context::Scope context_scope(GetV8Context()); 59 v8::Context::Scope context_scope(GetV8Context());
61 60
62 FXJSErr error; 61 FXJSErr error;
63 CFX_WideString wsInfo; 62 CFX_WideString wsInfo;
64 CFX_WideString wsScript(kScript); 63 CFX_WideString wsScript(kScript);
65 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error); 64 int sts = FXJS_Execute(isolate(), nullptr, kScript, wcslen(kScript), &error);
66 EXPECT_EQ(0, sts); 65 EXPECT_EQ(0, sts);
67 66
68 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate()); 67 v8::Local<v8::Object> This = FXJS_GetThisObj(isolate());
69 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred"); 68 v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred");
70 EXPECT_TRUE(fred->IsNumber()); 69 EXPECT_TRUE(fred->IsNumber());
71 } 70 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/util.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698