2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
2012-04-03 03:34:16 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include <sstream>
|
2014-07-15 00:18:51 +02:00
|
|
|
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/base/cef_bind.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "include/cef_task.h"
|
|
|
|
#include "include/cef_v8.h"
|
2014-07-15 20:10:40 +02:00
|
|
|
#include "include/wrapper/cef_closure_task.h"
|
2015-01-31 05:41:36 +01:00
|
|
|
#include "tests/cefclient/browser/client_app_browser.h"
|
|
|
|
#include "tests/cefclient/renderer/client_app_renderer.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
2014-07-15 00:18:51 +02:00
|
|
|
#include "tests/unittests/test_handler.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
using client::ClientAppBrowser;
|
|
|
|
using client::ClientAppRenderer;
|
2015-01-23 20:09:34 +01:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// How to add a new test:
|
|
|
|
// 1. Add a new value to the V8TestMode enumeration.
|
|
|
|
// 2. Add a method that implements the test in V8RendererTest.
|
|
|
|
// 3. Add a case for the new enumeration value in V8RendererTest::RunTest.
|
|
|
|
// 4. Add a line for the test in the "Define the tests" section at the bottom of
|
|
|
|
// the file.
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Unique values for V8 tests.
|
2012-10-29 22:46:02 +01:00
|
|
|
const char kV8TestUrl[] = "http://tests/V8Test.Test";
|
|
|
|
const char kV8BindingTestUrl[] = "http://tests/V8Test.BindingTest";
|
|
|
|
const char kV8ContextParentTestUrl[] = "http://tests/V8Test.ContextParentTest";
|
|
|
|
const char kV8ContextChildTestUrl[] = "http://tests/V8Test.ContextChildTest";
|
|
|
|
const char kV8NavTestUrl[] = "http://tests/V8Test.NavTest";
|
2012-11-02 19:16:28 +01:00
|
|
|
const char kV8OnUncaughtExceptionTestUrl[] =
|
|
|
|
"http://tests/V8Test.OnUncaughtException";
|
2012-10-29 22:46:02 +01:00
|
|
|
const char kV8TestMsg[] = "V8Test.Test";
|
|
|
|
const char kV8TestCmdArg[] = "v8-test";
|
2013-03-12 21:23:24 +01:00
|
|
|
const char kV8RunTestMsg[] = "V8Test.RunTest";
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
enum V8TestMode {
|
2012-09-28 19:11:10 +02:00
|
|
|
V8TEST_NONE = 0,
|
|
|
|
V8TEST_NULL_CREATE,
|
2012-04-03 03:34:16 +02:00
|
|
|
V8TEST_BOOL_CREATE,
|
|
|
|
V8TEST_INT_CREATE,
|
|
|
|
V8TEST_UINT_CREATE,
|
|
|
|
V8TEST_DOUBLE_CREATE,
|
|
|
|
V8TEST_DATE_CREATE,
|
|
|
|
V8TEST_STRING_CREATE,
|
2013-07-18 20:09:09 +02:00
|
|
|
V8TEST_EMPTY_STRING_CREATE,
|
2012-04-03 03:34:16 +02:00
|
|
|
V8TEST_ARRAY_CREATE,
|
|
|
|
V8TEST_ARRAY_VALUE,
|
|
|
|
V8TEST_OBJECT_CREATE,
|
|
|
|
V8TEST_OBJECT_USERDATA,
|
|
|
|
V8TEST_OBJECT_ACCESSOR,
|
|
|
|
V8TEST_OBJECT_ACCESSOR_EXCEPTION,
|
|
|
|
V8TEST_OBJECT_ACCESSOR_FAIL,
|
|
|
|
V8TEST_OBJECT_ACCESSOR_READONLY,
|
|
|
|
V8TEST_OBJECT_VALUE,
|
|
|
|
V8TEST_OBJECT_VALUE_READONLY,
|
|
|
|
V8TEST_OBJECT_VALUE_ENUM,
|
|
|
|
V8TEST_OBJECT_VALUE_DONTENUM,
|
|
|
|
V8TEST_OBJECT_VALUE_DELETE,
|
|
|
|
V8TEST_OBJECT_VALUE_DONTDELETE,
|
2012-09-26 23:26:32 +02:00
|
|
|
V8TEST_OBJECT_VALUE_EMPTYKEY,
|
2012-04-03 03:34:16 +02:00
|
|
|
V8TEST_FUNCTION_CREATE,
|
|
|
|
V8TEST_FUNCTION_HANDLER,
|
|
|
|
V8TEST_FUNCTION_HANDLER_EXCEPTION,
|
|
|
|
V8TEST_FUNCTION_HANDLER_FAIL,
|
|
|
|
V8TEST_FUNCTION_HANDLER_NO_OBJECT,
|
|
|
|
V8TEST_FUNCTION_HANDLER_WITH_CONTEXT,
|
2013-07-18 20:09:09 +02:00
|
|
|
V8TEST_FUNCTION_HANDLER_EMPTY_STRING,
|
2012-04-03 03:34:16 +02:00
|
|
|
V8TEST_CONTEXT_EVAL,
|
|
|
|
V8TEST_CONTEXT_EVAL_EXCEPTION,
|
|
|
|
V8TEST_CONTEXT_ENTERED,
|
2012-10-29 22:46:02 +01:00
|
|
|
V8TEST_CONTEXT_INVALID,
|
2012-04-03 03:34:16 +02:00
|
|
|
V8TEST_BINDING,
|
2012-07-25 13:50:35 +02:00
|
|
|
V8TEST_STACK_TRACE,
|
2012-11-02 19:16:28 +01:00
|
|
|
V8TEST_ON_UNCAUGHT_EXCEPTION,
|
|
|
|
V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS,
|
2013-01-03 18:24:24 +01:00
|
|
|
V8TEST_EXTENSION,
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Set to the current test being run in the browser process. Will always be
|
|
|
|
// V8TEST_NONE in the render process.
|
|
|
|
V8TestMode g_current_test_mode = V8TEST_NONE;
|
|
|
|
|
|
|
|
// Browser side.
|
2015-01-31 05:41:36 +01:00
|
|
|
class V8BrowserTest : public ClientAppBrowser::Delegate {
|
2012-09-28 19:11:10 +02:00
|
|
|
public:
|
|
|
|
V8BrowserTest() {}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnBeforeChildProcessLaunch(
|
2015-01-31 05:41:36 +01:00
|
|
|
CefRefPtr<ClientAppBrowser> app,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefCommandLine> command_line) override {
|
2012-09-28 19:11:10 +02:00
|
|
|
CefString process_type = command_line->GetSwitchValue("type");
|
|
|
|
if (process_type == "renderer") {
|
|
|
|
// Add the current test mode to the render process command line arguments.
|
|
|
|
char buff[33];
|
|
|
|
sprintf(buff, "%d", g_current_test_mode);
|
|
|
|
command_line->AppendSwitchWithValue(kV8TestCmdArg, buff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
IMPLEMENT_REFCOUNTING(V8BrowserTest);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Renderer side.
|
2015-01-31 05:41:36 +01:00
|
|
|
class V8RendererTest : public ClientAppRenderer::Delegate,
|
2013-11-08 17:06:06 +01:00
|
|
|
public CefLoadHandler {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2012-09-28 19:11:10 +02:00
|
|
|
V8RendererTest()
|
2013-11-08 17:06:06 +01:00
|
|
|
: test_mode_(V8TEST_NONE) {
|
2012-09-28 19:11:10 +02:00
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Run a test when the process message is received from the browser.
|
|
|
|
void RunTest() {
|
|
|
|
switch (test_mode_) {
|
2012-04-03 03:34:16 +02:00
|
|
|
case V8TEST_NULL_CREATE:
|
|
|
|
RunNullCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_BOOL_CREATE:
|
|
|
|
RunBoolCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_INT_CREATE:
|
|
|
|
RunIntCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_UINT_CREATE:
|
|
|
|
RunUIntCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_DOUBLE_CREATE:
|
|
|
|
RunDoubleCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_DATE_CREATE:
|
|
|
|
RunDateCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_STRING_CREATE:
|
|
|
|
RunStringCreateTest();
|
|
|
|
break;
|
2013-07-18 20:09:09 +02:00
|
|
|
case V8TEST_EMPTY_STRING_CREATE:
|
|
|
|
RunEmptyStringCreateTest();
|
|
|
|
break;
|
2012-04-03 03:34:16 +02:00
|
|
|
case V8TEST_ARRAY_CREATE:
|
|
|
|
RunArrayCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_ARRAY_VALUE:
|
|
|
|
RunArrayValueTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_CREATE:
|
|
|
|
RunObjectCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_USERDATA:
|
|
|
|
RunObjectUserDataTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_ACCESSOR:
|
|
|
|
RunObjectAccessorTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_ACCESSOR_EXCEPTION:
|
|
|
|
RunObjectAccessorExceptionTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_ACCESSOR_FAIL:
|
|
|
|
RunObjectAccessorFailTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_ACCESSOR_READONLY:
|
|
|
|
RunObjectAccessorReadOnlyTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE:
|
|
|
|
RunObjectValueTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE_READONLY:
|
|
|
|
RunObjectValueReadOnlyTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE_ENUM:
|
|
|
|
RunObjectValueEnumTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE_DONTENUM:
|
|
|
|
RunObjectValueDontEnumTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE_DELETE:
|
|
|
|
RunObjectValueDeleteTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_OBJECT_VALUE_DONTDELETE:
|
|
|
|
RunObjectValueDontDeleteTest();
|
|
|
|
break;
|
2012-09-26 23:26:32 +02:00
|
|
|
case V8TEST_OBJECT_VALUE_EMPTYKEY:
|
|
|
|
RunObjectValueEmptyKeyTest();
|
|
|
|
break;
|
2012-04-03 03:34:16 +02:00
|
|
|
case V8TEST_FUNCTION_CREATE:
|
|
|
|
RunFunctionCreateTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_FUNCTION_HANDLER:
|
|
|
|
RunFunctionHandlerTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_FUNCTION_HANDLER_EXCEPTION:
|
|
|
|
RunFunctionHandlerExceptionTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_FUNCTION_HANDLER_FAIL:
|
|
|
|
RunFunctionHandlerFailTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_FUNCTION_HANDLER_NO_OBJECT:
|
|
|
|
RunFunctionHandlerNoObjectTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_FUNCTION_HANDLER_WITH_CONTEXT:
|
|
|
|
RunFunctionHandlerWithContextTest();
|
|
|
|
break;
|
2013-07-18 20:09:09 +02:00
|
|
|
case V8TEST_FUNCTION_HANDLER_EMPTY_STRING:
|
|
|
|
RunFunctionHandlerEmptyStringTest();
|
|
|
|
break;
|
2012-04-03 03:34:16 +02:00
|
|
|
case V8TEST_CONTEXT_EVAL:
|
|
|
|
RunContextEvalTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_CONTEXT_EVAL_EXCEPTION:
|
|
|
|
RunContextEvalExceptionTest();
|
|
|
|
break;
|
|
|
|
case V8TEST_CONTEXT_ENTERED:
|
|
|
|
RunContextEnteredTest();
|
|
|
|
break;
|
2012-10-29 22:46:02 +01:00
|
|
|
case V8TEST_CONTEXT_INVALID:
|
|
|
|
// The test is triggered when the context is released.
|
|
|
|
browser_->GetMainFrame()->LoadURL(kV8NavTestUrl);
|
|
|
|
break;
|
2012-04-03 03:34:16 +02:00
|
|
|
case V8TEST_BINDING:
|
|
|
|
RunBindingTest();
|
|
|
|
break;
|
2012-07-25 13:50:35 +02:00
|
|
|
case V8TEST_STACK_TRACE:
|
|
|
|
RunStackTraceTest();
|
|
|
|
break;
|
2012-11-02 19:16:28 +01:00
|
|
|
case V8TEST_ON_UNCAUGHT_EXCEPTION:
|
|
|
|
RunOnUncaughtExceptionTest();
|
|
|
|
break;
|
2012-04-03 03:34:16 +02:00
|
|
|
default:
|
2012-09-28 19:11:10 +02:00
|
|
|
// Was a startup test.
|
|
|
|
EXPECT_TRUE(startup_test_success_);
|
2012-04-03 03:34:16 +02:00
|
|
|
DestroyTest();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Run a test on render process startup.
|
|
|
|
void RunStartupTest() {
|
|
|
|
switch (test_mode_) {
|
|
|
|
case V8TEST_EXTENSION:
|
|
|
|
RunExtensionTest();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void RunNullCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateNull();
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsNull());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunBoolCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateBool(true);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsBool());
|
|
|
|
EXPECT_EQ(true, value->GetBoolValue());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunIntCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateInt(12);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsInt());
|
|
|
|
EXPECT_TRUE(value->IsUInt());
|
|
|
|
EXPECT_TRUE(value->IsDouble());
|
|
|
|
EXPECT_EQ(12, value->GetIntValue());
|
|
|
|
EXPECT_EQ((uint32)12, value->GetUIntValue());
|
|
|
|
EXPECT_EQ(12, value->GetDoubleValue());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunUIntCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateUInt(12);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsInt());
|
|
|
|
EXPECT_TRUE(value->IsUInt());
|
|
|
|
EXPECT_TRUE(value->IsDouble());
|
|
|
|
EXPECT_EQ(12, value->GetIntValue());
|
|
|
|
EXPECT_EQ((uint32)12, value->GetUIntValue());
|
|
|
|
EXPECT_EQ(12, value->GetDoubleValue());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunDoubleCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateDouble(12.1223);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsDouble());
|
|
|
|
EXPECT_EQ(12.1223, value->GetDoubleValue());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunDateCreateTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
CefTime date;
|
|
|
|
date.year = 2200;
|
|
|
|
date.month = 4;
|
|
|
|
#if !defined(OS_MACOSX)
|
|
|
|
date.day_of_week = 5;
|
|
|
|
#endif
|
|
|
|
date.day_of_month = 11;
|
|
|
|
date.hour = 20;
|
|
|
|
date.minute = 15;
|
|
|
|
date.second = 42;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(date);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsDate());
|
|
|
|
EXPECT_EQ(date.GetTimeT(), value->GetDateValue().GetTimeT());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
2013-06-27 00:33:44 +02:00
|
|
|
EXPECT_FALSE(value->IsObject());
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunStringCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateString("My string");
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsString());
|
|
|
|
EXPECT_STREQ("My string", value->GetStringValue().ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2013-07-18 20:09:09 +02:00
|
|
|
void RunEmptyStringCreateTest() {
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateString(CefString());
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsString());
|
|
|
|
EXPECT_STREQ("", value->GetStringValue().ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsObject());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void RunArrayCreateTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateArray(2);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsArray());
|
|
|
|
EXPECT_TRUE(value->IsObject());
|
|
|
|
EXPECT_EQ(2, value->GetArrayLength());
|
|
|
|
EXPECT_FALSE(value->HasValue(0));
|
|
|
|
EXPECT_FALSE(value->HasValue(1));
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunArrayValueTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateArray(0);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsArray());
|
|
|
|
EXPECT_EQ(0, value->GetArrayLength());
|
|
|
|
|
|
|
|
// Test addng values.
|
|
|
|
EXPECT_FALSE(value->HasValue(0));
|
|
|
|
EXPECT_FALSE(value->HasValue(1));
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->SetValue(0, CefV8Value::CreateInt(10)));
|
|
|
|
EXPECT_FALSE(value->HasException());
|
|
|
|
EXPECT_TRUE(value->HasValue(0));
|
|
|
|
EXPECT_FALSE(value->HasValue(1));
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->GetValue(0)->IsInt());
|
|
|
|
EXPECT_EQ(10, value->GetValue(0)->GetIntValue());
|
|
|
|
EXPECT_FALSE(value->HasException());
|
|
|
|
EXPECT_EQ(1, value->GetArrayLength());
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->SetValue(1, CefV8Value::CreateInt(43)));
|
|
|
|
EXPECT_FALSE(value->HasException());
|
|
|
|
EXPECT_TRUE(value->HasValue(0));
|
|
|
|
EXPECT_TRUE(value->HasValue(1));
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->GetValue(1)->IsInt());
|
|
|
|
EXPECT_EQ(43, value->GetValue(1)->GetIntValue());
|
|
|
|
EXPECT_FALSE(value->HasException());
|
|
|
|
EXPECT_EQ(2, value->GetArrayLength());
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->DeleteValue(0));
|
|
|
|
EXPECT_FALSE(value->HasValue(0));
|
|
|
|
EXPECT_TRUE(value->HasValue(1));
|
|
|
|
EXPECT_EQ(2, value->GetArrayLength());
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->DeleteValue(1));
|
|
|
|
EXPECT_FALSE(value->HasValue(0));
|
|
|
|
EXPECT_FALSE(value->HasValue(1));
|
|
|
|
EXPECT_EQ(2, value->GetArrayLength());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectCreateTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(NULL);
|
|
|
|
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsObject());
|
|
|
|
EXPECT_FALSE(value->GetUserData().get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsFunction());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
2015-12-09 17:10:16 +01:00
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectUserDataTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class UserData : public CefBase {
|
|
|
|
public:
|
|
|
|
explicit UserData(int value) : value_(value) {}
|
|
|
|
int value_;
|
|
|
|
IMPLEMENT_REFCOUNTING(UserData);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(NULL);
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
|
|
|
|
EXPECT_TRUE(value->SetUserData(new UserData(10)));
|
|
|
|
|
|
|
|
CefRefPtr<CefBase> user_data = value->GetUserData();
|
|
|
|
EXPECT_TRUE(user_data.get());
|
|
|
|
UserData* user_data_impl = static_cast<UserData*>(user_data.get());
|
|
|
|
EXPECT_EQ(10, user_data_impl->value_);
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectAccessorTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "val";
|
|
|
|
static const int kValue = 20;
|
|
|
|
|
|
|
|
class Accessor : public CefV8Accessor {
|
|
|
|
public:
|
|
|
|
Accessor() : value_(0) {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Get(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_STREQ(kName, name.ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
EXPECT_TRUE(object->IsSame(object_));
|
|
|
|
|
|
|
|
EXPECT_FALSE(retval.get());
|
|
|
|
EXPECT_TRUE(exception.empty());
|
|
|
|
|
|
|
|
got_get_.yes();
|
|
|
|
retval = CefV8Value::CreateInt(value_);
|
|
|
|
EXPECT_EQ(kValue, retval->GetIntValue());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Set(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
const CefRefPtr<CefV8Value> value,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_STREQ(kName, name.ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
EXPECT_TRUE(object->IsSame(object_));
|
|
|
|
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(exception.empty());
|
|
|
|
|
|
|
|
got_set_.yes();
|
|
|
|
value_ = value->GetIntValue();
|
|
|
|
EXPECT_EQ(kValue, value_);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object_;
|
|
|
|
int value_;
|
|
|
|
TrackCallback got_get_;
|
|
|
|
TrackCallback got_set_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Accessor);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Accessor* accessor = new Accessor;
|
|
|
|
CefRefPtr<CefV8Accessor> accessorPtr(accessor);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = CefV8Value::CreateObject(accessor);
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
accessor->object_ = object;
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, V8_ACCESS_CONTROL_DEFAULT,
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, CefV8Value::CreateInt(kValue),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_set_);
|
|
|
|
EXPECT_EQ(kValue, accessor->value_);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> val = object->GetValue(kName);
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(val.get());
|
|
|
|
EXPECT_TRUE(accessor->got_get_);
|
|
|
|
EXPECT_TRUE(val->IsInt());
|
|
|
|
EXPECT_EQ(kValue, val->GetIntValue());
|
|
|
|
|
|
|
|
accessor->object_ = NULL;
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectAccessorExceptionTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "val";
|
|
|
|
static const char* kGetException = "My get exception";
|
|
|
|
static const char* kSetException = "My set exception";
|
|
|
|
static const char* kGetExceptionMsg = "Uncaught Error: My get exception";
|
|
|
|
static const char* kSetExceptionMsg = "Uncaught Error: My set exception";
|
|
|
|
|
|
|
|
class Accessor : public CefV8Accessor {
|
|
|
|
public:
|
|
|
|
Accessor() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Get(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_get_.yes();
|
|
|
|
exception = kGetException;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Set(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
const CefRefPtr<CefV8Value> value,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_set_.yes();
|
|
|
|
exception = kSetException;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_get_;
|
|
|
|
TrackCallback got_set_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Accessor);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
Accessor* accessor = new Accessor;
|
|
|
|
CefRefPtr<CefV8Accessor> accessorPtr(accessor);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = CefV8Value::CreateObject(accessor);
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, V8_ACCESS_CONTROL_DEFAULT,
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->SetValue(kName, CefV8Value::CreateInt(1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_TRUE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_set_);
|
|
|
|
exception = object->GetException();
|
|
|
|
EXPECT_TRUE(exception.get());
|
|
|
|
EXPECT_STREQ(kSetExceptionMsg, exception->GetMessage().ToString().c_str());
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->ClearException());
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> val = object->GetValue(kName);
|
|
|
|
EXPECT_FALSE(val.get());
|
|
|
|
EXPECT_TRUE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_get_);
|
|
|
|
exception = object->GetException();
|
|
|
|
EXPECT_TRUE(exception.get());
|
|
|
|
EXPECT_STREQ(kGetExceptionMsg, exception->GetMessage().ToString().c_str());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectAccessorFailTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "val";
|
|
|
|
|
|
|
|
class Accessor : public CefV8Accessor {
|
|
|
|
public:
|
|
|
|
Accessor() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Get(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_get_.yes();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Set(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
const CefRefPtr<CefV8Value> value,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_set_.yes();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_get_;
|
|
|
|
TrackCallback got_set_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Accessor);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
Accessor* accessor = new Accessor;
|
|
|
|
CefRefPtr<CefV8Accessor> accessorPtr(accessor);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = CefV8Value::CreateObject(accessor);
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, V8_ACCESS_CONTROL_DEFAULT,
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, CefV8Value::CreateInt(1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_set_);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> val = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(val.get());
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_get_);
|
|
|
|
EXPECT_TRUE(val->IsUndefined());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectAccessorReadOnlyTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "val";
|
|
|
|
|
|
|
|
class Accessor : public CefV8Accessor {
|
|
|
|
public:
|
|
|
|
Accessor() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Get(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_get_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Set(const CefString& name,
|
|
|
|
const CefRefPtr<CefV8Value> object,
|
|
|
|
const CefRefPtr<CefV8Value> value,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_set_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_get_;
|
|
|
|
TrackCallback got_set_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Accessor);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
Accessor* accessor = new Accessor;
|
|
|
|
CefRefPtr<CefV8Accessor> accessorPtr(accessor);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = CefV8Value::CreateObject(accessor);
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, V8_ACCESS_CONTROL_DEFAULT,
|
|
|
|
V8_PROPERTY_ATTRIBUTE_READONLY));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(object->HasValue(kName));
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->SetValue(kName, CefV8Value::CreateInt(1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_FALSE(accessor->got_set_);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> val = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(val.get());
|
|
|
|
EXPECT_FALSE(object->HasException());
|
|
|
|
EXPECT_TRUE(accessor->got_get_);
|
|
|
|
EXPECT_TRUE(val->IsUndefined());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "test_arg";
|
|
|
|
static const int kVal1 = 13;
|
|
|
|
static const int kVal2 = 65;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
object->SetValue(kName, CefV8Value::CreateInt(kVal1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"if (window." << kName << " != " << kVal1 << ") throw 'Fail';\n" <<
|
|
|
|
"window." << kName << " = " << kVal2 << ";";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(kVal2, newval->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueReadOnlyTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "test_arg";
|
|
|
|
static const int kVal1 = 13;
|
|
|
|
static const int kVal2 = 65;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
object->SetValue(kName, CefV8Value::CreateInt(kVal1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_READONLY);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"if (window." << kName << " != " << kVal1 << ") throw 'Fail';\n" <<
|
|
|
|
"window." << kName << " = " << kVal2 << ";";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(kVal1, newval->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueEnumTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kObjName = "test_obj";
|
|
|
|
static const char* kArgName = "test_arg";
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> obj1 = CefV8Value::CreateObject(NULL);
|
|
|
|
object->SetValue(kObjName, obj1, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
obj1->SetValue(kArgName, CefV8Value::CreateInt(0),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"for (var i in window." << kObjName << ") {\n"
|
|
|
|
"window." << kObjName << "[i]++;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = obj1->GetValue(kArgName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(1, newval->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueDontEnumTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kObjName = "test_obj";
|
|
|
|
static const char* kArgName = "test_arg";
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> obj1 = CefV8Value::CreateObject(NULL);
|
|
|
|
object->SetValue(kObjName, obj1, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
obj1->SetValue(kArgName, CefV8Value::CreateInt(0),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_DONTENUM);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"for (var i in window." << kObjName << ") {\n"
|
|
|
|
"window." << kObjName << "[i]++;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = obj1->GetValue(kArgName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(0, newval->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueDeleteTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "test_arg";
|
|
|
|
static const int kVal1 = 13;
|
|
|
|
static const int kVal2 = 65;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
object->SetValue(kName, CefV8Value::CreateInt(kVal1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"if (window." << kName << " != " << kVal1 << ") throw 'Fail';\n" <<
|
|
|
|
"window." << kName << " = " << kVal2 << ";\n"
|
|
|
|
"delete window." << kName << ";";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsUndefined());
|
|
|
|
EXPECT_FALSE(newval->IsInt());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunObjectValueDontDeleteTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "test_arg";
|
|
|
|
static const int kVal1 = 13;
|
|
|
|
static const int kVal2 = 65;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
object->SetValue(kName, CefV8Value::CreateInt(kVal1),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_DONTDELETE);
|
|
|
|
|
|
|
|
std::stringstream test;
|
|
|
|
test <<
|
|
|
|
"if (window." << kName << " != " << kVal1 << ") throw 'Fail';\n" <<
|
|
|
|
"window." << kName << " = " << kVal2 << ";\n"
|
|
|
|
"delete window." << kName << ";";
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(test.str(), retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(kVal2, newval->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-09-26 23:26:32 +02:00
|
|
|
void RunObjectValueEmptyKeyTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kName = "";
|
|
|
|
static const int kVal = 13;
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
object->SetValue(kName, CefV8Value::CreateInt(kVal),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
EXPECT_TRUE(object->HasValue(kName));
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> newval = object->GetValue(kName);
|
|
|
|
EXPECT_TRUE(newval.get());
|
|
|
|
EXPECT_TRUE(newval->IsInt());
|
|
|
|
EXPECT_EQ(kVal, newval->GetIntValue());
|
|
|
|
|
|
|
|
EXPECT_TRUE(object->DeleteValue(kName));
|
|
|
|
EXPECT_FALSE(object->HasValue(kName));
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void RunFunctionCreateTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override { return false; }
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateFunction("f", new Handler);
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsFunction());
|
|
|
|
EXPECT_TRUE(value->IsObject());
|
|
|
|
|
|
|
|
EXPECT_FALSE(value->IsUndefined());
|
|
|
|
EXPECT_FALSE(value->IsArray());
|
|
|
|
EXPECT_FALSE(value->IsBool());
|
|
|
|
EXPECT_FALSE(value->IsDate());
|
|
|
|
EXPECT_FALSE(value->IsDouble());
|
|
|
|
EXPECT_FALSE(value->IsInt());
|
|
|
|
EXPECT_FALSE(value->IsUInt());
|
|
|
|
EXPECT_FALSE(value->IsNull());
|
|
|
|
EXPECT_FALSE(value->IsString());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunFunctionHandlerTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kFuncName = "myfunc";
|
|
|
|
static const int kVal1 = 32;
|
|
|
|
static const int kVal2 = 41;
|
|
|
|
static const int kRetVal = 8;
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_STREQ(kFuncName, name.ToString().c_str());
|
|
|
|
EXPECT_TRUE(object->IsSame(object_));
|
|
|
|
|
|
|
|
EXPECT_EQ((size_t)2, arguments.size());
|
|
|
|
EXPECT_TRUE(arguments[0]->IsInt());
|
|
|
|
EXPECT_EQ(kVal1, arguments[0]->GetIntValue());
|
|
|
|
EXPECT_TRUE(arguments[1]->IsInt());
|
|
|
|
EXPECT_EQ(kVal2, arguments[1]->GetIntValue());
|
|
|
|
|
|
|
|
EXPECT_TRUE(exception.empty());
|
|
|
|
|
|
|
|
retval = CefV8Value::CreateInt(kRetVal);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_EQ(kRetVal, retval->GetIntValue());
|
|
|
|
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object_;
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction(kFuncName, handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(NULL);
|
|
|
|
EXPECT_TRUE(obj.get());
|
|
|
|
handler->object_ = obj;
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
args.push_back(CefV8Value::CreateInt(kVal1));
|
|
|
|
args.push_back(CefV8Value::CreateInt(kVal2));
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval = func->ExecuteFunction(obj, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_FALSE(func->HasException());
|
|
|
|
EXPECT_TRUE(retval->IsInt());
|
|
|
|
EXPECT_EQ(kRetVal, retval->GetIntValue());
|
|
|
|
|
|
|
|
handler->object_ = NULL;
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunFunctionHandlerExceptionTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kException = "My error";
|
|
|
|
static const char* kExceptionMsg = "Uncaught Error: My error";
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
exception = kException;
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("myfunc", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval = func->ExecuteFunction(NULL, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_FALSE(retval.get());
|
|
|
|
EXPECT_TRUE(func->HasException());
|
|
|
|
CefRefPtr<CefV8Exception> exception = func->GetException();
|
|
|
|
EXPECT_TRUE(exception.get());
|
|
|
|
EXPECT_STREQ(kExceptionMsg, exception->GetMessage().ToString().c_str());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunFunctionHandlerFailTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
got_execute_.yes();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("myfunc", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval = func->ExecuteFunction(NULL, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_FALSE(func->HasException());
|
|
|
|
EXPECT_TRUE(retval->IsUndefined());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunFunctionHandlerNoObjectTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(global.get());
|
|
|
|
EXPECT_TRUE(global->IsSame(object));
|
|
|
|
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("myfunc", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval = func->ExecuteFunction(NULL, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_FALSE(func->HasException());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunFunctionHandlerWithContextTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
EXPECT_TRUE(context->IsSame(context_));
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Context> context_;
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
handler->context_ = context;
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("myfunc", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval =
|
|
|
|
func->ExecuteFunctionWithContext(context, NULL, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_FALSE(func->HasException());
|
|
|
|
|
|
|
|
handler->context_ = NULL;
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2013-07-18 20:09:09 +02:00
|
|
|
void RunFunctionHandlerEmptyStringTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2013-07-18 20:09:09 +02:00
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(global.get());
|
|
|
|
EXPECT_TRUE(global->IsSame(object));
|
|
|
|
|
|
|
|
EXPECT_EQ((size_t)1, arguments.size());
|
|
|
|
EXPECT_TRUE(arguments[0]->IsString());
|
|
|
|
EXPECT_STREQ("", arguments[0]->GetStringValue().ToString().c_str());
|
|
|
|
|
|
|
|
retval = CefV8Value::CreateString(CefString());
|
|
|
|
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("myfunc", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefV8ValueList args;
|
|
|
|
args.push_back(CefV8Value::CreateString(CefString()));
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval = func->ExecuteFunction(NULL, args);
|
|
|
|
EXPECT_TRUE(handler->got_execute_);
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_FALSE(func->HasException());
|
|
|
|
|
|
|
|
EXPECT_TRUE(retval->IsString());
|
|
|
|
EXPECT_STREQ("", retval->GetStringValue().ToString().c_str());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void RunContextEvalTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval("1+2", retval, exception));
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_TRUE(retval->IsInt());
|
|
|
|
EXPECT_EQ(3, retval->GetIntValue());
|
|
|
|
EXPECT_FALSE(exception.get());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunContextEvalExceptionTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_FALSE(context->Eval("1+foo", retval, exception));
|
|
|
|
EXPECT_FALSE(retval.get());
|
|
|
|
EXPECT_TRUE(exception.get());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunContextEnteredTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
// Test value defined in OnContextCreated
|
|
|
|
EXPECT_TRUE(context->Eval(
|
|
|
|
"document.getElementById('f').contentWindow.v8_context_entered_test()",
|
|
|
|
retval, exception));
|
|
|
|
if (exception.get())
|
|
|
|
ADD_FAILURE() << exception->GetMessage().c_str();
|
|
|
|
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_TRUE(retval->IsInt());
|
|
|
|
EXPECT_EQ(21, retval->GetIntValue());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RunBindingTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
|
|
|
|
// Test value defined in OnContextCreated
|
|
|
|
CefRefPtr<CefV8Value> value = object->GetValue("v8_binding_test");
|
|
|
|
EXPECT_TRUE(value.get());
|
|
|
|
EXPECT_TRUE(value->IsInt());
|
|
|
|
EXPECT_EQ(12, value->GetIntValue());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-07-25 13:50:35 +02:00
|
|
|
void RunStackTraceTest() {
|
|
|
|
CefRefPtr<CefV8Context> context = GetContext();
|
|
|
|
|
|
|
|
static const char* kFuncName = "myfunc";
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-07-25 13:50:35 +02:00
|
|
|
EXPECT_STREQ(kFuncName, name.ToString().c_str());
|
|
|
|
|
|
|
|
stack_trace_ = CefV8StackTrace::GetCurrent(10);
|
|
|
|
|
|
|
|
retval = CefV8Value::CreateInt(3);
|
|
|
|
got_execute_.yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback got_execute_;
|
|
|
|
CefRefPtr<CefV8StackTrace> stack_trace_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enter the V8 context.
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction(kFuncName, handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
CefRefPtr<CefV8Value> obj = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(obj.get());
|
|
|
|
obj->SetValue(kFuncName, func, V8_PROPERTY_ATTRIBUTE_NONE);
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Eval(
|
|
|
|
"function jsfunc() { return window.myfunc(); }\n"
|
|
|
|
"jsfunc();",
|
|
|
|
retval, exception));
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
EXPECT_TRUE(retval->IsInt());
|
|
|
|
EXPECT_EQ(3, retval->GetIntValue());
|
|
|
|
EXPECT_FALSE(exception.get());
|
|
|
|
|
|
|
|
EXPECT_TRUE(handler->stack_trace_.get());
|
|
|
|
EXPECT_EQ(2, handler->stack_trace_->GetFrameCount());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8StackFrame> frame;
|
|
|
|
|
|
|
|
frame = handler->stack_trace_->GetFrame(0);
|
|
|
|
EXPECT_TRUE(frame->GetScriptName().empty());
|
|
|
|
EXPECT_TRUE(frame->GetScriptNameOrSourceURL().empty());
|
|
|
|
EXPECT_STREQ("jsfunc", frame->GetFunctionName().ToString().c_str());
|
|
|
|
EXPECT_EQ(1, frame->GetLineNumber());
|
|
|
|
EXPECT_EQ(35, frame->GetColumn());
|
|
|
|
EXPECT_TRUE(frame.get());
|
|
|
|
EXPECT_TRUE(frame->IsEval());
|
|
|
|
EXPECT_FALSE(frame->IsConstructor());
|
|
|
|
|
|
|
|
frame = handler->stack_trace_->GetFrame(1);
|
|
|
|
EXPECT_TRUE(frame->GetScriptName().empty());
|
|
|
|
EXPECT_TRUE(frame->GetScriptNameOrSourceURL().empty());
|
|
|
|
EXPECT_TRUE(frame->GetFunctionName().empty());
|
|
|
|
EXPECT_EQ(2, frame->GetLineNumber());
|
|
|
|
EXPECT_EQ(1, frame->GetColumn());
|
|
|
|
EXPECT_TRUE(frame.get());
|
|
|
|
EXPECT_TRUE(frame->IsEval());
|
|
|
|
EXPECT_FALSE(frame->IsConstructor());
|
|
|
|
|
|
|
|
// Exit the V8 context.
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
void RunOnUncaughtExceptionTest() {
|
|
|
|
test_context_ =
|
|
|
|
browser_->GetMainFrame()->GetV8Context();
|
|
|
|
browser_->GetMainFrame()->ExecuteJavaScript(
|
2013-03-12 21:23:24 +01:00
|
|
|
"window.setTimeout(test, 0)", browser_->GetMainFrame()->GetURL(), 0);
|
2012-11-02 19:16:28 +01:00
|
|
|
}
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Test execution of a native function when the extension is loaded.
|
|
|
|
void RunExtensionTest() {
|
|
|
|
std::string code = "native function v8_extension_test();"
|
|
|
|
"v8_extension_test();";
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler(TrackCallback* callback)
|
|
|
|
: callback_(callback) {
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-09-28 19:11:10 +02:00
|
|
|
EXPECT_STREQ("v8_extension_test", name.ToString().c_str());
|
|
|
|
callback_->yes();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackCallback* callback_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
CefRegisterExtension("v8/test-extension", code,
|
|
|
|
new Handler(&startup_test_success_));
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowser> browser) override {
|
2012-09-28 19:11:10 +02:00
|
|
|
test_mode_ = g_current_test_mode;
|
|
|
|
if (test_mode_ == V8TEST_NONE) {
|
|
|
|
// Retrieve the test mode from the command line.
|
|
|
|
CefRefPtr<CefCommandLine> command_line =
|
|
|
|
CefCommandLine::GetGlobalCommandLine();
|
|
|
|
CefString value = command_line->GetSwitchValue(kV8TestCmdArg);
|
|
|
|
if (!value.empty())
|
|
|
|
test_mode_ = static_cast<V8TestMode>(atoi(value.ToString().c_str()));
|
|
|
|
}
|
2012-10-03 23:35:04 +02:00
|
|
|
if (test_mode_ > V8TEST_NONE)
|
|
|
|
RunStartupTest();
|
2012-09-28 19:11:10 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
|
|
|
CefRefPtr<ClientAppRenderer> app) override {
|
2013-11-08 17:06:06 +01:00
|
|
|
if (test_mode_ == V8TEST_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
2013-11-08 17:06:06 +01:00
|
|
|
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS &&
|
|
|
|
browser->IsPopup()) {
|
|
|
|
DevToolsLoadHook(browser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) override {
|
2012-12-22 17:55:25 +01:00
|
|
|
if (test_mode_ == V8TEST_NONE)
|
|
|
|
return;
|
|
|
|
|
2013-04-11 22:46:04 +02:00
|
|
|
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
2013-11-08 17:06:06 +01:00
|
|
|
if (!browser->IsPopup()) {
|
2012-11-02 19:16:28 +01:00
|
|
|
app_ = app;
|
|
|
|
browser_ = browser;
|
2013-11-08 17:06:06 +01:00
|
|
|
test_context_ = context;
|
2012-11-02 19:16:28 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
app_ = app;
|
|
|
|
browser_ = browser;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
std::string url = frame->GetURL();
|
|
|
|
if (url == kV8ContextChildTestUrl) {
|
|
|
|
// For V8TEST_CONTEXT_ENTERED
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
// context for the sub-frame
|
|
|
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
|
|
|
|
// entered context should be the same as the main frame context
|
|
|
|
CefRefPtr<CefV8Context> entered = CefV8Context::GetEnteredContext();
|
|
|
|
EXPECT_TRUE(entered.get());
|
|
|
|
EXPECT_TRUE(entered->IsSame(context_));
|
|
|
|
|
|
|
|
context_ = NULL;
|
|
|
|
retval = CefV8Value::CreateInt(21);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Context> context_;
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
|
|
|
|
// main frame context
|
|
|
|
handler->context_ = GetContext();
|
|
|
|
|
|
|
|
// Function that will be called from the parent frame context.
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction("v8_context_entered_test", handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
EXPECT_TRUE(object->SetValue("v8_context_entered_test", func,
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
2012-09-28 19:11:10 +02:00
|
|
|
} else if (url == kV8ContextParentTestUrl) {
|
|
|
|
// For V8TEST_CONTEXT_ENTERED. Do nothing.
|
|
|
|
return;
|
2012-04-03 03:34:16 +02:00
|
|
|
} else if (url == kV8BindingTestUrl) {
|
|
|
|
// For V8TEST_BINDING
|
|
|
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
|
|
|
EXPECT_TRUE(object.get());
|
|
|
|
EXPECT_TRUE(object->SetValue("v8_binding_test",
|
|
|
|
CefV8Value::CreateInt(12),
|
|
|
|
V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) override {
|
2012-12-22 17:55:25 +01:00
|
|
|
if (test_mode_ == V8TEST_NONE)
|
|
|
|
return;
|
|
|
|
|
2012-10-29 22:46:02 +01:00
|
|
|
if (test_mode_ == V8TEST_CONTEXT_INVALID &&
|
2013-02-06 21:41:54 +01:00
|
|
|
frame->GetURL().ToString() == kV8TestUrl) {
|
2012-10-29 22:46:02 +01:00
|
|
|
test_context_ =
|
|
|
|
browser_->GetMainFrame()->GetV8Context();
|
|
|
|
test_object_ = CefV8Value::CreateArray(10);
|
2014-07-15 20:10:40 +02:00
|
|
|
CefPostTask(TID_RENDERER, base::Bind(&V8RendererTest::DestroyTest, this));
|
2012-10-29 22:46:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnUncaughtException(CefRefPtr<ClientAppRenderer> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context,
|
|
|
|
CefRefPtr<CefV8Exception> exception,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefV8StackTrace> stackTrace) override {
|
2013-01-03 18:24:24 +01:00
|
|
|
if (test_mode_ == V8TEST_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
|
|
|
test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
|
|
|
EXPECT_TRUE(test_context_->IsSame(context));
|
|
|
|
EXPECT_STREQ("Uncaught ReferenceError: asd is not defined",
|
|
|
|
exception->GetMessage().ToString().c_str());
|
|
|
|
std::ostringstream stackFormatted;
|
|
|
|
for (int i = 0; i < stackTrace->GetFrameCount(); ++i) {
|
|
|
|
stackFormatted << "at "
|
|
|
|
<< stackTrace->GetFrame(i)->GetFunctionName().ToString()
|
|
|
|
<< "() in " << stackTrace->GetFrame(i)->GetScriptName().ToString()
|
|
|
|
<< " on line " << stackTrace->GetFrame(i)->GetLineNumber() << "\n";
|
|
|
|
}
|
|
|
|
const char* stackFormattedShouldBe =
|
|
|
|
"at test2() in http://tests/V8Test.OnUncaughtException on line 3\n"
|
|
|
|
"at test() in http://tests/V8Test.OnUncaughtException on line 2\n";
|
|
|
|
EXPECT_STREQ(stackFormattedShouldBe, stackFormatted.str().c_str());
|
|
|
|
DestroyTest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
bool OnProcessMessageReceived(CefRefPtr<ClientAppRenderer> app,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) override {
|
2012-12-22 17:55:25 +01:00
|
|
|
if (test_mode_ == V8TEST_NONE)
|
|
|
|
return false;
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
const std::string& message_name = message->GetName();
|
|
|
|
if (message_name == kV8RunTestMsg) {
|
2013-03-12 21:23:24 +01:00
|
|
|
// Run the test asynchronously.
|
2014-07-15 20:10:40 +02:00
|
|
|
CefPostTask(TID_RENDERER, base::Bind(&V8RendererTest::RunTest, this));
|
2013-03-12 21:23:24 +01:00
|
|
|
return true;
|
2012-11-02 19:16:28 +01:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsLoadHook(CefRefPtr<CefBrowser> browser) {
|
|
|
|
EXPECT_TRUE(browser->IsPopup());
|
2014-12-13 21:18:31 +01:00
|
|
|
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
|
|
|
|
CefRefPtr<CefV8Context> context = frame->GetV8Context();
|
2012-11-02 19:16:28 +01:00
|
|
|
static const char* kFuncName = "DevToolsLoaded";
|
|
|
|
|
|
|
|
class Handler : public CefV8Handler {
|
|
|
|
public:
|
|
|
|
Handler() {}
|
2014-11-12 20:25:15 +01:00
|
|
|
bool Execute(const CefString& name,
|
|
|
|
CefRefPtr<CefV8Value> object,
|
|
|
|
const CefV8ValueList& arguments,
|
|
|
|
CefRefPtr<CefV8Value>& retval,
|
|
|
|
CefString& exception) override {
|
2012-11-02 19:16:28 +01:00
|
|
|
EXPECT_STREQ(kFuncName, name.ToString().c_str());
|
|
|
|
if (name == kFuncName) {
|
|
|
|
EXPECT_TRUE(exception.empty());
|
|
|
|
retval = CefV8Value::CreateNull();
|
|
|
|
EXPECT_TRUE(retval.get());
|
|
|
|
renderer_test_->DevToolsLoaded(browser_);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CefRefPtr<V8RendererTest> renderer_test_;
|
|
|
|
CefRefPtr<CefBrowser> browser_;
|
|
|
|
IMPLEMENT_REFCOUNTING(Handler);
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPECT_TRUE(context->Enter());
|
|
|
|
Handler* handler = new Handler;
|
|
|
|
handler->renderer_test_ = this;
|
|
|
|
handler->browser_ = browser;
|
|
|
|
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
|
|
|
CefRefPtr<CefV8Value> func =
|
|
|
|
CefV8Value::CreateFunction(kFuncName, handler);
|
|
|
|
EXPECT_TRUE(func.get());
|
|
|
|
EXPECT_TRUE(context->GetGlobal()->SetValue(
|
|
|
|
kFuncName, func, V8_PROPERTY_ATTRIBUTE_NONE));
|
|
|
|
EXPECT_TRUE(context->Exit());
|
|
|
|
|
2014-12-13 21:18:31 +01:00
|
|
|
// Dismiss the DevTools window after 500ms. It would be better to hook the
|
|
|
|
// DevTools JS to receive notification of when loading is complete but that
|
|
|
|
// is no longer possible.
|
|
|
|
CefPostDelayedTask(TID_RENDERER,
|
|
|
|
base::Bind(&CefFrame::ExecuteJavaScript, frame.get(),
|
|
|
|
"window.DevToolsLoaded()", frame->GetURL(), 0),
|
|
|
|
500);
|
2012-11-02 19:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DevToolsLoaded(CefRefPtr<CefBrowser> browser) {
|
|
|
|
EXPECT_TRUE(browser->IsPopup());
|
2013-11-08 17:06:06 +01:00
|
|
|
// |browser_| will be NULL if the DevTools window is opened in a separate
|
|
|
|
// render process.
|
|
|
|
const int other_browser_id =
|
|
|
|
(browser_.get() ? browser_->GetIdentifier() : -1);
|
|
|
|
EXPECT_NE(browser->GetIdentifier(), other_browser_id);
|
|
|
|
|
|
|
|
// Close the DevTools window. This will trigger OnBeforeClose in the browser
|
|
|
|
// process.
|
2012-11-02 19:16:28 +01:00
|
|
|
CefRefPtr<CefV8Value> retval;
|
|
|
|
CefRefPtr<CefV8Exception> exception;
|
|
|
|
EXPECT_TRUE(browser->GetMainFrame()->GetV8Context()->Eval(
|
|
|
|
"window.close()", retval, exception));
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
protected:
|
|
|
|
// Return from the test.
|
|
|
|
void DestroyTest() {
|
2013-01-03 18:24:24 +01:00
|
|
|
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
|
|
|
|
2012-10-29 22:46:02 +01:00
|
|
|
if (test_mode_ == V8TEST_CONTEXT_INVALID) {
|
|
|
|
// Verify that objects related to a particular context are not valid after
|
|
|
|
// OnContextReleased is called for that context.
|
|
|
|
EXPECT_FALSE(test_context_->IsValid());
|
|
|
|
EXPECT_FALSE(test_object_->IsValid());
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Check if the test has failed.
|
2012-04-12 22:21:50 +02:00
|
|
|
bool result = !TestFailed();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Return the result to the browser process.
|
|
|
|
CefRefPtr<CefProcessMessage> return_msg =
|
|
|
|
CefProcessMessage::Create(kV8TestMsg);
|
|
|
|
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
|
|
|
EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg));
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
app_ = NULL;
|
2012-04-03 03:34:16 +02:00
|
|
|
browser_ = NULL;
|
2012-11-02 19:16:28 +01:00
|
|
|
test_context_ = NULL;
|
|
|
|
test_object_ = NULL;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return the V8 context.
|
|
|
|
CefRefPtr<CefV8Context> GetContext() {
|
|
|
|
CefRefPtr<CefV8Context> context = browser_->GetMainFrame()->GetV8Context();
|
|
|
|
EXPECT_TRUE(context.get());
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
CefRefPtr<ClientAppRenderer> app_;
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser_;
|
2012-09-28 19:11:10 +02:00
|
|
|
V8TestMode test_mode_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-10-29 22:46:02 +01:00
|
|
|
CefRefPtr<CefV8Context> test_context_;
|
|
|
|
CefRefPtr<CefV8Value> test_object_;
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Used by startup tests to indicate success.
|
|
|
|
TrackCallback startup_test_success_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(V8RendererTest);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Browser side.
|
|
|
|
class V8TestHandler : public TestHandler {
|
|
|
|
public:
|
2012-06-19 18:29:49 +02:00
|
|
|
V8TestHandler(V8TestMode test_mode, const char* test_url)
|
2012-04-03 03:34:16 +02:00
|
|
|
: test_mode_(test_mode),
|
|
|
|
test_url_(test_url) {
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void RunTest() override {
|
2012-09-28 19:11:10 +02:00
|
|
|
// Nested script tag forces creation of the V8 context.
|
2012-04-03 03:34:16 +02:00
|
|
|
if (test_mode_ == V8TEST_CONTEXT_ENTERED) {
|
2012-09-28 19:11:10 +02:00
|
|
|
AddResource(kV8ContextParentTestUrl, "<html><body>"
|
|
|
|
"<script>var i = 0;</script><iframe src=\"" +
|
2012-04-03 03:34:16 +02:00
|
|
|
std::string(kV8ContextChildTestUrl) + "\" id=\"f\"></iframe></body>"
|
|
|
|
"</html>", "text/html");
|
2012-09-28 19:11:10 +02:00
|
|
|
AddResource(kV8ContextChildTestUrl, "<html><body>"
|
|
|
|
"<script>var i = 0;</script>CHILD</body></html>",
|
2012-04-03 03:34:16 +02:00
|
|
|
"text/html");
|
|
|
|
CreateBrowser(kV8ContextParentTestUrl);
|
2012-11-02 19:16:28 +01:00
|
|
|
} else if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
|
|
|
test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
|
|
|
AddResource(kV8OnUncaughtExceptionTestUrl, "<html><body>"
|
|
|
|
"<h1>OnUncaughtException</h1>"
|
|
|
|
"<script>\n"
|
|
|
|
"function test(){ test2(); }\n"
|
|
|
|
"function test2(){ asd(); }\n"
|
|
|
|
"</script>\n"
|
|
|
|
"</body></html>\n",
|
|
|
|
"text/html");
|
|
|
|
CreateBrowser(kV8OnUncaughtExceptionTestUrl);
|
2012-04-03 03:34:16 +02:00
|
|
|
} else {
|
|
|
|
EXPECT_TRUE(test_url_ != NULL);
|
2012-09-28 19:11:10 +02:00
|
|
|
AddResource(test_url_, "<html><body>"
|
|
|
|
"<script>var i = 0;</script>TEST</body></html>", "text/html");
|
2012-04-03 03:34:16 +02:00
|
|
|
CreateBrowser(test_url_);
|
|
|
|
}
|
2015-01-10 00:40:26 +01:00
|
|
|
|
|
|
|
// Time out the test after a reasonable period of time.
|
|
|
|
SetTestTimeout();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override {
|
2013-11-08 17:06:06 +01:00
|
|
|
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS &&
|
|
|
|
browser->IsPopup()) {
|
2015-06-06 00:06:48 +02:00
|
|
|
// Generate the uncaught exception in the main browser. Use a 200ms delay
|
|
|
|
// because there's a bit of a lag between destroying the DevToolsAgent and
|
|
|
|
// re-registering for uncaught exceptions.
|
2013-11-08 17:06:06 +01:00
|
|
|
GetBrowser()->GetMainFrame()->ExecuteJavaScript(
|
2015-06-06 00:06:48 +02:00
|
|
|
"window.setTimeout(test, 200);",
|
2013-11-08 17:06:06 +01:00
|
|
|
GetBrowser()->GetMainFrame()->GetURL(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TestHandler::OnBeforeClose(browser);
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
int httpStatusCode) override {
|
2013-04-11 22:46:04 +02:00
|
|
|
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
2013-11-08 17:06:06 +01:00
|
|
|
if (!browser->IsPopup()) {
|
|
|
|
// Create the DevTools window.
|
|
|
|
CefWindowInfo windowInfo;
|
|
|
|
CefBrowserSettings settings;
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
windowInfo.SetAsPopup(browser->GetHost()->GetWindowHandle(), "DevTools");
|
|
|
|
#endif
|
|
|
|
|
2014-10-11 02:12:01 +02:00
|
|
|
browser->GetHost()->ShowDevTools(windowInfo, this, settings,
|
|
|
|
CefPoint());
|
2013-03-12 21:23:24 +01:00
|
|
|
}
|
2013-11-08 17:06:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& url = frame->GetURL();
|
|
|
|
if (url != kV8NavTestUrl && url != kV8ContextParentTestUrl &&
|
|
|
|
url.find("http://tests/") != std::string::npos) {
|
|
|
|
// Run the test.
|
|
|
|
CefRefPtr<CefProcessMessage> return_msg =
|
|
|
|
CefProcessMessage::Create(kV8RunTestMsg);
|
|
|
|
EXPECT_TRUE(browser->SendProcessMessage(PID_RENDERER, return_msg));
|
2012-11-02 19:16:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
bool OnProcessMessageReceived(
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefProcessId source_process,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefProcessMessage> message) override {
|
2012-04-03 03:34:16 +02:00
|
|
|
EXPECT_TRUE(browser.get());
|
|
|
|
EXPECT_EQ(PID_RENDERER, source_process);
|
|
|
|
EXPECT_TRUE(message.get());
|
|
|
|
EXPECT_TRUE(message->IsReadOnly());
|
|
|
|
|
2013-11-08 17:06:06 +01:00
|
|
|
const std::string& message_name = message->GetName();
|
|
|
|
EXPECT_STREQ(kV8TestMsg, message_name.c_str());
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
got_message_.yes();
|
|
|
|
|
|
|
|
if (message->GetArgumentList()->GetBool(0))
|
|
|
|
got_success_.yes();
|
|
|
|
|
|
|
|
// Test is complete.
|
|
|
|
DestroyTest();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
V8TestMode test_mode_;
|
|
|
|
const char* test_url_;
|
|
|
|
TrackCallback got_message_;
|
|
|
|
TrackCallback got_success_;
|
2015-09-09 16:05:39 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(V8TestHandler);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
2012-09-28 19:11:10 +02:00
|
|
|
// Entry point for creating V8 browser test objects.
|
|
|
|
// Called from client_app_delegates.cc.
|
2015-01-31 05:41:36 +01:00
|
|
|
void CreateV8BrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
2012-09-28 19:11:10 +02:00
|
|
|
delegates.insert(new V8BrowserTest);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Entry point for creating V8 renderer test objects.
|
2012-04-12 22:21:50 +02:00
|
|
|
// Called from client_app_delegates.cc.
|
2015-01-31 05:41:36 +01:00
|
|
|
void CreateV8RendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
2012-04-12 22:21:50 +02:00
|
|
|
delegates.insert(new V8RendererTest);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Helpers for defining V8 tests.
|
|
|
|
#define V8_TEST_EX(name, test_mode, test_url) \
|
|
|
|
TEST(V8Test, name) { \
|
2012-09-28 19:11:10 +02:00
|
|
|
g_current_test_mode = test_mode; \
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<V8TestHandler> handler = \
|
|
|
|
new V8TestHandler(test_mode, test_url); \
|
|
|
|
handler->ExecuteTest(); \
|
|
|
|
EXPECT_TRUE(handler->got_message_); \
|
|
|
|
EXPECT_TRUE(handler->got_success_); \
|
2012-10-03 23:35:04 +02:00
|
|
|
g_current_test_mode = V8TEST_NONE; \
|
2015-01-10 00:40:26 +01:00
|
|
|
ReleaseAndWaitForDestructor(handler); \
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define V8_TEST(name, test_mode) \
|
|
|
|
V8_TEST_EX(name, test_mode, kV8TestUrl)
|
|
|
|
|
|
|
|
|
|
|
|
// Define the tests.
|
|
|
|
V8_TEST(NullCreate, V8TEST_NULL_CREATE);
|
|
|
|
V8_TEST(BoolCreate, V8TEST_BOOL_CREATE);
|
|
|
|
V8_TEST(IntCreate, V8TEST_INT_CREATE);
|
|
|
|
V8_TEST(UIntCreate, V8TEST_UINT_CREATE);
|
|
|
|
V8_TEST(DoubleCreate, V8TEST_DOUBLE_CREATE);
|
|
|
|
V8_TEST(DateCreate, V8TEST_DATE_CREATE);
|
|
|
|
V8_TEST(StringCreate, V8TEST_STRING_CREATE);
|
2013-07-18 20:09:09 +02:00
|
|
|
V8_TEST(EmptyStringCreate, V8TEST_EMPTY_STRING_CREATE);
|
2012-04-03 03:34:16 +02:00
|
|
|
V8_TEST(ArrayCreate, V8TEST_ARRAY_CREATE);
|
|
|
|
V8_TEST(ArrayValue, V8TEST_ARRAY_VALUE);
|
|
|
|
V8_TEST(ObjectCreate, V8TEST_OBJECT_CREATE);
|
|
|
|
V8_TEST(ObjectUserData, V8TEST_OBJECT_USERDATA);
|
|
|
|
V8_TEST(ObjectAccessor, V8TEST_OBJECT_ACCESSOR);
|
|
|
|
V8_TEST(ObjectAccessorException, V8TEST_OBJECT_ACCESSOR_EXCEPTION);
|
|
|
|
V8_TEST(ObjectAccessorFail, V8TEST_OBJECT_ACCESSOR_FAIL);
|
|
|
|
V8_TEST(ObjectAccessorReadOnly, V8TEST_OBJECT_ACCESSOR_READONLY);
|
|
|
|
V8_TEST(ObjectValue, V8TEST_OBJECT_VALUE);
|
|
|
|
V8_TEST(ObjectValueReadOnly, V8TEST_OBJECT_VALUE_READONLY);
|
|
|
|
V8_TEST(ObjectValueEnum, V8TEST_OBJECT_VALUE_ENUM);
|
|
|
|
V8_TEST(ObjectValueDontEnum, V8TEST_OBJECT_VALUE_DONTENUM);
|
|
|
|
V8_TEST(ObjectValueDelete, V8TEST_OBJECT_VALUE_DELETE);
|
|
|
|
V8_TEST(ObjectValueDontDelete, V8TEST_OBJECT_VALUE_DONTDELETE);
|
2012-09-26 23:26:32 +02:00
|
|
|
V8_TEST(ObjectValueEmptyKey, V8TEST_OBJECT_VALUE_EMPTYKEY);
|
2012-04-03 03:34:16 +02:00
|
|
|
V8_TEST(FunctionCreate, V8TEST_FUNCTION_CREATE);
|
|
|
|
V8_TEST(FunctionHandler, V8TEST_FUNCTION_HANDLER);
|
|
|
|
V8_TEST(FunctionHandlerException, V8TEST_FUNCTION_HANDLER_EXCEPTION);
|
|
|
|
V8_TEST(FunctionHandlerFail, V8TEST_FUNCTION_HANDLER_FAIL);
|
|
|
|
V8_TEST(FunctionHandlerNoObject, V8TEST_FUNCTION_HANDLER_NO_OBJECT);
|
|
|
|
V8_TEST(FunctionHandlerWithContext, V8TEST_FUNCTION_HANDLER_WITH_CONTEXT);
|
2013-07-18 20:09:09 +02:00
|
|
|
V8_TEST(FunctionHandlerEmptyString, V8TEST_FUNCTION_HANDLER_EMPTY_STRING);
|
2012-04-03 03:34:16 +02:00
|
|
|
V8_TEST(ContextEval, V8TEST_CONTEXT_EVAL);
|
|
|
|
V8_TEST(ContextEvalException, V8TEST_CONTEXT_EVAL_EXCEPTION);
|
|
|
|
V8_TEST_EX(ContextEntered, V8TEST_CONTEXT_ENTERED, NULL);
|
2012-10-29 22:46:02 +01:00
|
|
|
V8_TEST(ContextInvalid, V8TEST_CONTEXT_INVALID);
|
2012-04-03 03:34:16 +02:00
|
|
|
V8_TEST_EX(Binding, V8TEST_BINDING, kV8BindingTestUrl);
|
2012-07-25 13:50:35 +02:00
|
|
|
V8_TEST(StackTrace, V8TEST_STACK_TRACE);
|
2012-11-02 19:16:28 +01:00
|
|
|
V8_TEST(OnUncaughtException, V8TEST_ON_UNCAUGHT_EXCEPTION);
|
|
|
|
V8_TEST(OnUncaughtExceptionDevTools, V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS);
|
2012-09-28 19:11:10 +02:00
|
|
|
V8_TEST(Extension, V8TEST_EXTENSION);
|