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

Side by Side Diff: testing/test_support.cpp

Issue 1424743006: Make JS app.setTimeOut() work again. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 1 month 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
« fpdfsdk/src/javascript/JS_Object.cpp ('K') | « testing/test_support.h ('k') | no next file » | 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 "test_support.h" 5 #include "test_support.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #ifdef _WIN32 10 #ifdef _WIN32
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 (void)fclose(file); 91 (void)fclose(file);
92 if (bytes_read != file_length) { 92 if (bytes_read != file_length) {
93 fprintf(stderr, "Failed to read: %s\n", filename); 93 fprintf(stderr, "Failed to read: %s\n", filename);
94 free(buffer); 94 free(buffer);
95 return nullptr; 95 return nullptr;
96 } 96 }
97 *retlen = bytes_read; 97 *retlen = bytes_read;
98 return buffer; 98 return buffer;
99 } 99 }
100 100
101 wchar_t* GetWideString(FPDF_WIDESTRING wstr) {
102 size_t characters = 0;
103 while (wstr[characters])
104 ++characters;
105
106 wchar_t* platform_string =
107 static_cast<wchar_t*>(malloc((characters + 1) * sizeof(wchar_t)));
108 for (size_t i = 0; i < characters + 1; ++i) {
109 unsigned char* ptr = (unsigned char*)&wstr[i];
110 platform_string[i] = ptr[0] + 256 * ptr[1];
111 }
112 return platform_string;
113 }
114
101 #ifdef PDF_ENABLE_V8 115 #ifdef PDF_ENABLE_V8
102 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 116 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
103 bool InitializeV8ForPDFium(const std::string& exe_path, 117 bool InitializeV8ForPDFium(const std::string& exe_path,
104 const std::string& bin_dir, 118 const std::string& bin_dir,
105 v8::StartupData* natives_blob, 119 v8::StartupData* natives_blob,
106 v8::StartupData* snapshot_blob, 120 v8::StartupData* snapshot_blob,
107 v8::Platform** platform) { 121 v8::Platform** platform) {
108 InitializeV8Common(platform); 122 InitializeV8Common(platform);
109 if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob)) 123 if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
110 return false; 124 return false;
(...skipping 20 matching lines...) Expand all
131 unsigned long pos, 145 unsigned long pos,
132 unsigned char* pBuf, 146 unsigned char* pBuf,
133 unsigned long size) { 147 unsigned long size) {
134 TestLoader* pLoader = static_cast<TestLoader*>(param); 148 TestLoader* pLoader = static_cast<TestLoader*>(param);
135 if (pos + size < pos || pos + size > pLoader->m_Len) 149 if (pos + size < pos || pos + size > pLoader->m_Len)
136 return 0; 150 return 0;
137 151
138 memcpy(pBuf, pLoader->m_pBuf + pos, size); 152 memcpy(pBuf, pLoader->m_pBuf + pos, size);
139 return 1; 153 return 1;
140 } 154 }
OLDNEW
« fpdfsdk/src/javascript/JS_Object.cpp ('K') | « testing/test_support.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698