mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 20:50:42 +01:00
Merge revision 879, revision 883 and revision 885 changes:
- Add performance tests for CEF V8 methods (issue #484). - Support implicit detachment of CEF V8 references when the associated context is released (issue #484). - Reduce persistent CEF V8 memory usage by tracking objects on a per-context basis and not persisting objects when the underlying V8 handle is unused (issue #484). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1271@887 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
32341bc7eb
commit
335a024b85
@ -93,10 +93,14 @@
|
||||
'tests/cefclient/download_handler.h',
|
||||
'tests/cefclient/extension_test.cpp',
|
||||
'tests/cefclient/extension_test.h',
|
||||
'tests/cefclient/performance_test.cpp',
|
||||
'tests/cefclient/performance_test.h',
|
||||
'tests/cefclient/performance_test_setup.h',
|
||||
'tests/cefclient/performance_test_tests.cpp',
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/extensionperf.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/performance.html',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
'tests/cefclient/resource_util.h',
|
||||
'tests/cefclient/scheme_test.cpp',
|
||||
@ -149,10 +153,10 @@
|
||||
'tests/cefclient/mac/English.lproj/MainMenu.xib',
|
||||
'tests/cefclient/mac/Info.plist',
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/extensionperf.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/logoball.png',
|
||||
'tests/cefclient/res/performance.html',
|
||||
'tests/cefclient/res/osrtest.html',
|
||||
'tests/cefclient/res/transparency.html',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
@ -164,9 +168,9 @@
|
||||
],
|
||||
'cefclient_bundle_resources_linux': [
|
||||
'tests/cefclient/res/domaccess.html',
|
||||
'tests/cefclient/res/extensionperf.html',
|
||||
'tests/cefclient/res/localstorage.html',
|
||||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/performance.html',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
],
|
||||
},
|
||||
|
@ -114,6 +114,12 @@ typedef struct _cef_v8context_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is valid. Do not call any other functions
|
||||
// if this function returns false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *is_valid)(struct _cef_v8context_t* self);
|
||||
|
||||
///
|
||||
// Returns the browser for this context.
|
||||
///
|
||||
@ -314,6 +320,12 @@ typedef struct _cef_v8value_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is valid. Do not call any other functions
|
||||
// if this function returns false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *is_valid)(struct _cef_v8value_t* self);
|
||||
|
||||
///
|
||||
// True if the value type is undefined.
|
||||
///
|
||||
@ -708,6 +720,12 @@ typedef struct _cef_v8stack_trace_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is valid. Do not call any other functions
|
||||
// if this function returns false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_trace_t* self);
|
||||
|
||||
///
|
||||
// Returns the number of stack frames.
|
||||
///
|
||||
@ -738,6 +756,12 @@ typedef struct _cef_v8stack_frame_t {
|
||||
///
|
||||
cef_base_t base;
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is valid. Do not call any other functions
|
||||
// if this function returns false (0).
|
||||
///
|
||||
int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_frame_t* self);
|
||||
|
||||
///
|
||||
// Returns the name of the resource script that contains the function.
|
||||
///
|
||||
|
@ -140,6 +140,13 @@ class CefV8Context : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
static bool InContext();
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// Returns the browser for this context.
|
||||
///
|
||||
@ -407,6 +414,13 @@ class CefV8Value : public virtual CefBase {
|
||||
static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
|
||||
CefRefPtr<CefV8Handler> handler);
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// True if the value type is undefined.
|
||||
///
|
||||
@ -754,6 +768,13 @@ class CefV8StackTrace : public virtual CefBase {
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefV8StackTrace> GetCurrent(int frame_limit);
|
||||
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// Returns the number of stack frames.
|
||||
///
|
||||
@ -774,6 +795,13 @@ class CefV8StackTrace : public virtual CefBase {
|
||||
/*--cef(source=library)--*/
|
||||
class CefV8StackFrame : public virtual CefBase {
|
||||
public:
|
||||
///
|
||||
// Returns true if this object is valid. Do not call any other methods if this
|
||||
// method returns false.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool IsValid() =0;
|
||||
|
||||
///
|
||||
// Returns the name of the resource script that contains the function.
|
||||
///
|
||||
|
@ -69,6 +69,18 @@ CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
|
||||
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
|
||||
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
|
||||
|
||||
///
|
||||
// Retrieve the current system time.
|
||||
//
|
||||
CEF_EXPORT int cef_time_now(cef_time_t* cef_time);
|
||||
|
||||
///
|
||||
// Retrieve the delta in milliseconds between two time values.
|
||||
//
|
||||
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
|
||||
const cef_time_t* cef_time2,
|
||||
long long* delta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -218,6 +218,25 @@ typedef struct _cef_settings_t {
|
||||
// OnUncaughtException() will not be called.
|
||||
///
|
||||
int uncaught_exception_stack_size;
|
||||
|
||||
///
|
||||
// By default CEF V8 references will be invalidated (the IsValid() method will
|
||||
// return false) after the owning context has been released. This reduces the
|
||||
// need for external record keeping and avoids crashes due to the use of V8
|
||||
// references after the associated context has been released.
|
||||
//
|
||||
// CEF currently offers two context safety implementations with different
|
||||
// performance characteristics. The default implementation (value of 0) uses a
|
||||
// map of hash values and should provide better performance in situations with
|
||||
// a small number contexts. The alternate implementation (value of 1) uses a
|
||||
// hidden value attached to each context and should provide better performance
|
||||
// in situations with a large number of contexts.
|
||||
//
|
||||
// If you need better performance in the creation of V8 references and you
|
||||
// plan to manually track context lifespan you can disable context safety by
|
||||
// specifying a value of -1.
|
||||
///
|
||||
int context_safety_implementation;
|
||||
} cef_settings_t;
|
||||
|
||||
///
|
||||
|
@ -300,6 +300,7 @@ struct CefSettingsTraits {
|
||||
&target->locales_dir_path, copy);
|
||||
target->pack_loading_disabled = src->pack_loading_disabled;
|
||||
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
|
||||
target->context_safety_implementation = src->context_safety_implementation;
|
||||
}
|
||||
};
|
||||
|
||||
@ -499,6 +500,18 @@ class CefTime : public CefStructBase<CefTimeTraits> {
|
||||
cef_time_to_doublet(this, &time);
|
||||
return time;
|
||||
}
|
||||
|
||||
// Set this object to now.
|
||||
void Now() {
|
||||
cef_time_now(this);
|
||||
}
|
||||
|
||||
// Return the delta between this object and |other| in milliseconds.
|
||||
int64 Delta(const CefTime& other) {
|
||||
int64 delta = 0;
|
||||
cef_time_delta(this, &other, &delta);
|
||||
return delta;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -921,20 +921,21 @@ void BrowserWebViewDelegate::didCreateScriptContext(
|
||||
void BrowserWebViewDelegate::willReleaseScriptContext(
|
||||
WebFrame* frame, v8::Handle<v8::Context> context, int worldId) {
|
||||
CefRefPtr<CefClient> client = browser_->GetClient();
|
||||
if (!client.get())
|
||||
return;
|
||||
if (client.get()) {
|
||||
CefRefPtr<CefV8ContextHandler> handler = client->GetV8ContextHandler();
|
||||
if (handler.get()) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
CefRefPtr<CefV8ContextHandler> handler = client->GetV8ContextHandler();
|
||||
if (!handler.get())
|
||||
return;
|
||||
CefRefPtr<CefFrame> framePtr(browser_->UIT_GetCefFrame(frame));
|
||||
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Context::Scope scope(context);
|
||||
handler->OnContextReleased(browser_, framePtr, contextPtr);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> framePtr(browser_->UIT_GetCefFrame(frame));
|
||||
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
|
||||
|
||||
handler->OnContextReleased(browser_, framePtr, contextPtr);
|
||||
// Disconnect any handles still associated with the context.
|
||||
CefV8ReleaseContext(context);
|
||||
}
|
||||
|
||||
void BrowserWebViewDelegate::didReceiveTitle(
|
||||
|
@ -67,3 +67,27 @@ CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time) {
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_now(cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
return 0;
|
||||
|
||||
base::Time base_time = base::Time::Now();
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
|
||||
const cef_time_t* cef_time2,
|
||||
long long* delta) {
|
||||
if (!cef_time1 || !cef_time2 || !delta)
|
||||
return 0;
|
||||
|
||||
base::Time base_time1, base_time2;
|
||||
cef_time_to_basetime(*cef_time1, base_time1);
|
||||
cef_time_to_basetime(*cef_time2, base_time2);
|
||||
|
||||
base::TimeDelta time_delta = base_time2 - base_time1;
|
||||
*delta = time_delta.InMilliseconds();
|
||||
return 1;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
@ -43,19 +44,133 @@ MSVC_POP_WARNING();
|
||||
namespace {
|
||||
|
||||
static const char kCefTrackObject[] = "Cef::TrackObject";
|
||||
static const char kCefContextState[] = "Cef::ContextState";
|
||||
|
||||
// Memory manager.
|
||||
|
||||
base::LazyInstance<CefTrackManager> g_v8_tracker = LAZY_INSTANCE_INITIALIZER;
|
||||
class CefV8TrackManager {
|
||||
public:
|
||||
CefV8TrackManager() {
|
||||
const CefSettings& settings = _Context->settings();
|
||||
if (settings.context_safety_implementation < 0)
|
||||
context_safety_impl_ = IMPL_DISABLED;
|
||||
else if (settings.context_safety_implementation == 1)
|
||||
context_safety_impl_ = IMPL_VALUE;
|
||||
else
|
||||
context_safety_impl_ = IMPL_HASH;
|
||||
}
|
||||
|
||||
scoped_refptr<CefV8ContextState> GetContextState(
|
||||
v8::Handle<v8::Context> context) {
|
||||
if (context_safety_impl_ == IMPL_DISABLED)
|
||||
return scoped_refptr<CefV8ContextState>();
|
||||
|
||||
if (context.IsEmpty()) {
|
||||
if (v8::Context::InContext())
|
||||
context = v8::Context::GetCurrent();
|
||||
else
|
||||
return scoped_refptr<CefV8ContextState>();
|
||||
}
|
||||
|
||||
if (context_safety_impl_ == IMPL_HASH) {
|
||||
int hash = context->Global()->GetIdentityHash();
|
||||
ContextMap::const_iterator it = context_map_.find(hash);
|
||||
if (it != context_map_.end())
|
||||
return it->second;
|
||||
|
||||
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
||||
context_map_.insert(std::make_pair(hash, state));
|
||||
|
||||
return state;
|
||||
} else {
|
||||
if (context_state_key_.IsEmpty()) {
|
||||
context_state_key_ =
|
||||
v8::Persistent<v8::String>::New(v8::String::New(kCefContextState));
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> object = context->Global();
|
||||
v8::Handle<v8::Value> value = object->GetHiddenValue(context_state_key_);
|
||||
if (!value.IsEmpty())
|
||||
return static_cast<CefV8ContextState*>(v8::External::Unwrap(value));
|
||||
|
||||
scoped_refptr<CefV8ContextState> state = new CefV8ContextState();
|
||||
object->SetHiddenValue(context_state_key_,
|
||||
v8::External::New(state.get()));
|
||||
|
||||
// Reference will be released in ReleaseContext.
|
||||
state->AddRef();
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseContext(v8::Handle<v8::Context> context) {
|
||||
if (context_safety_impl_ == IMPL_DISABLED)
|
||||
return;
|
||||
|
||||
if (context_safety_impl_ == IMPL_HASH) {
|
||||
int hash = context->Global()->GetIdentityHash();
|
||||
ContextMap::iterator it = context_map_.find(hash);
|
||||
if (it != context_map_.end()) {
|
||||
it->second->Detach();
|
||||
context_map_.erase(it);
|
||||
}
|
||||
} else {
|
||||
if (context_state_key_.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Handle<v8::Object> object = context->Global();
|
||||
v8::Handle<v8::Value> value = object->GetHiddenValue(context_state_key_);
|
||||
scoped_refptr<CefV8ContextState> state =
|
||||
static_cast<CefV8ContextState*>(v8::External::Unwrap(value));
|
||||
state->Detach();
|
||||
object->DeleteHiddenValue(context_state_key_);
|
||||
|
||||
// Match the AddRef in GetContextState.
|
||||
state->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void AddGlobalTrackObject(CefTrackNode* object) {
|
||||
global_manager_.Add(object);
|
||||
}
|
||||
|
||||
void DeleteGlobalTrackObject(CefTrackNode* object) {
|
||||
global_manager_.Delete(object);
|
||||
}
|
||||
|
||||
private:
|
||||
enum ContextSafetyImpl {
|
||||
IMPL_DISABLED,
|
||||
IMPL_HASH,
|
||||
IMPL_VALUE,
|
||||
};
|
||||
ContextSafetyImpl context_safety_impl_;
|
||||
|
||||
// Used with IMPL_HASH.
|
||||
typedef std::map<int, scoped_refptr<CefV8ContextState> > ContextMap;
|
||||
ContextMap context_map_;
|
||||
|
||||
// Used with IMPL_VALUE.
|
||||
v8::Persistent<v8::String> context_state_key_;
|
||||
|
||||
// Used for globally tracked objects that are not associated with a particular
|
||||
// context.
|
||||
CefTrackManager global_manager_;
|
||||
};
|
||||
|
||||
base::LazyInstance<CefV8TrackManager> g_v8_tracker = LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
class V8TrackObject : public CefTrackNode {
|
||||
public:
|
||||
V8TrackObject()
|
||||
: external_memory_(0) {
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(
|
||||
static_cast<int>(sizeof(V8TrackObject)));
|
||||
}
|
||||
~V8TrackObject() {
|
||||
if (external_memory_ != 0)
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(-external_memory_);
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(
|
||||
-static_cast<int>(sizeof(V8TrackObject)) - external_memory_);
|
||||
}
|
||||
|
||||
inline int GetExternallyAllocatedMemory() {
|
||||
@ -133,18 +248,56 @@ class V8TrackString : public CefTrackNode {
|
||||
std::string string_;
|
||||
};
|
||||
|
||||
void TrackAdd(CefTrackNode* object) {
|
||||
g_v8_tracker.Pointer()->Add(object);
|
||||
}
|
||||
|
||||
void TrackDelete(CefTrackNode* object) {
|
||||
g_v8_tracker.Pointer()->Delete(object);
|
||||
}
|
||||
// Manages the life span of a CefTrackNode associated with a persistent Object
|
||||
// or Function.
|
||||
class CefV8MakeWeakParam {
|
||||
public:
|
||||
CefV8MakeWeakParam(scoped_refptr<CefV8ContextState> context_state,
|
||||
CefTrackNode* object)
|
||||
: context_state_(context_state),
|
||||
object_(object) {
|
||||
DCHECK(object_);
|
||||
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(
|
||||
static_cast<int>(sizeof(CefV8MakeWeakParam)));
|
||||
|
||||
if (context_state_.get()) {
|
||||
// |object_| will be deleted when:
|
||||
// A. The associated context is released, or
|
||||
// B. TrackDestructor is called for the weak handle.
|
||||
DCHECK(context_state_->IsValid());
|
||||
context_state_->AddTrackObject(object_);
|
||||
} else {
|
||||
// |object_| will be deleted when:
|
||||
// A. The process shuts down, or
|
||||
// B. TrackDestructor is called for the weak handle.
|
||||
g_v8_tracker.Pointer()->AddGlobalTrackObject(object_);
|
||||
}
|
||||
}
|
||||
~CefV8MakeWeakParam() {
|
||||
if (context_state_.get()) {
|
||||
// If the associated context is still valid then delete |object_|.
|
||||
// Otherwise, |object_| will already have been deleted.
|
||||
if (context_state_->IsValid())
|
||||
context_state_->DeleteTrackObject(object_);
|
||||
} else {
|
||||
g_v8_tracker.Pointer()->DeleteGlobalTrackObject(object_);
|
||||
}
|
||||
|
||||
v8::V8::AdjustAmountOfExternalAllocatedMemory(
|
||||
-static_cast<int>(sizeof(CefV8MakeWeakParam)));
|
||||
}
|
||||
|
||||
private:
|
||||
scoped_refptr<CefV8ContextState> context_state_;
|
||||
CefTrackNode* object_;
|
||||
};
|
||||
|
||||
// Callback for weak persistent reference destruction.
|
||||
void TrackDestructor(v8::Persistent<v8::Value> object, void* parameter) {
|
||||
if (parameter)
|
||||
TrackDelete(static_cast<CefTrackNode*>(parameter));
|
||||
delete static_cast<CefV8MakeWeakParam*>(parameter);
|
||||
|
||||
object.Dispose();
|
||||
object.Clear();
|
||||
@ -262,7 +415,7 @@ v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args) {
|
||||
} else {
|
||||
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
||||
if (rv)
|
||||
return rv->GetHandle();
|
||||
return rv->GetHandle(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +447,7 @@ v8::Handle<v8::Value> AccessorGetterCallbackImpl(v8::Local<v8::String> property,
|
||||
} else {
|
||||
CefV8ValueImpl* rv = static_cast<CefV8ValueImpl*>(retval.get());
|
||||
if (rv)
|
||||
return rv->GetHandle();
|
||||
return rv->GetHandle(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -340,7 +493,7 @@ class ExtensionWrapper : public v8::Extension {
|
||||
// The reference will be released when the process exits.
|
||||
V8TrackObject* object = new V8TrackObject;
|
||||
object->SetHandler(handler);
|
||||
TrackAdd(object);
|
||||
g_v8_tracker.Pointer()->AddGlobalTrackObject(object);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,6 +570,10 @@ class CefV8ExceptionImpl : public CefV8Exception {
|
||||
|
||||
// Global functions.
|
||||
|
||||
void CefV8ReleaseContext(v8::Handle<v8::Context> context) {
|
||||
g_v8_tracker.Pointer()->ReleaseContext(context);
|
||||
}
|
||||
|
||||
bool CefRegisterExtension(const CefString& extension_name,
|
||||
const CefString& javascript_code,
|
||||
CefRefPtr<CefV8Handler> handler) {
|
||||
@ -424,9 +581,9 @@ bool CefRegisterExtension(const CefString& extension_name,
|
||||
CEF_REQUIRE_VALID_CONTEXT(false);
|
||||
|
||||
V8TrackString* name = new V8TrackString(extension_name);
|
||||
TrackAdd(name);
|
||||
g_v8_tracker.Pointer()->AddGlobalTrackObject(name);
|
||||
V8TrackString* code = new V8TrackString(javascript_code);
|
||||
TrackAdd(code);
|
||||
g_v8_tracker.Pointer()->AddGlobalTrackObject(code);
|
||||
|
||||
ExtensionWrapper* wrapper = new ExtensionWrapper(name->GetString(),
|
||||
code->GetString(), handler.get());
|
||||
@ -437,6 +594,13 @@ bool CefRegisterExtension(const CefString& extension_name,
|
||||
}
|
||||
|
||||
|
||||
// CefV8HandleBase
|
||||
|
||||
CefV8HandleBase::CefV8HandleBase(v8::Handle<v8::Context> context) {
|
||||
context_state_ = g_v8_tracker.Pointer()->GetContextState(context);
|
||||
}
|
||||
|
||||
|
||||
// CefV8Context
|
||||
|
||||
// static
|
||||
@ -473,26 +637,35 @@ bool CefV8Context::InContext() {
|
||||
|
||||
// CefV8ContextImpl
|
||||
|
||||
#define CEF_V8_REQUIRE_VALID_RETURN(ret) \
|
||||
if (!handle_->IsValid()) { \
|
||||
NOTREACHED() << "V8 handle is not valid"; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define CEF_V8_REQUIRE_OBJECT_RETURN(ret) \
|
||||
if (!GetHandle()->IsObject()) { \
|
||||
CEF_V8_REQUIRE_VALID_RETURN(ret); \
|
||||
if (!GetHandle(false)->IsObject()) { \
|
||||
NOTREACHED() << "V8 value is not an object"; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define CEF_V8_REQUIRE_ARRAY_RETURN(ret) \
|
||||
if (!GetHandle()->IsArray()) { \
|
||||
CEF_V8_REQUIRE_VALID_RETURN(ret); \
|
||||
if (!GetHandle(false)->IsArray()) { \
|
||||
NOTREACHED() << "V8 value is not an array"; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define CEF_V8_REQUIRE_FUNCTION_RETURN(ret) \
|
||||
if (!GetHandle()->IsFunction()) { \
|
||||
CEF_V8_REQUIRE_VALID_RETURN(ret); \
|
||||
if (!GetHandle(false)->IsFunction()) { \
|
||||
NOTREACHED() << "V8 value is not a function"; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
CefV8ContextImpl::CefV8ContextImpl(v8::Handle<v8::Context> context)
|
||||
: handle_(new Handle(context))
|
||||
: handle_(new Handle(context, context))
|
||||
#ifndef NDEBUG
|
||||
, enter_count_(0)
|
||||
#endif
|
||||
@ -503,9 +676,15 @@ CefV8ContextImpl::~CefV8ContextImpl() {
|
||||
DLOG_ASSERT(0 == enter_count_);
|
||||
}
|
||||
|
||||
bool CefV8ContextImpl::IsValid() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return handle_->IsValid();
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefV8ContextImpl::GetBrowser() {
|
||||
CefRefPtr<CefBrowser> browser;
|
||||
CEF_REQUIRE_UI_THREAD(browser);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(browser);
|
||||
|
||||
WebKit::WebFrame* webframe = GetWebFrame();
|
||||
if (webframe)
|
||||
@ -517,6 +696,7 @@ CefRefPtr<CefBrowser> CefV8ContextImpl::GetBrowser() {
|
||||
CefRefPtr<CefFrame> CefV8ContextImpl::GetFrame() {
|
||||
CefRefPtr<CefFrame> frame;
|
||||
CEF_REQUIRE_UI_THREAD(frame);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(frame);
|
||||
|
||||
WebKit::WebFrame* webframe = GetWebFrame();
|
||||
if (webframe) {
|
||||
@ -531,6 +711,7 @@ CefRefPtr<CefFrame> CefV8ContextImpl::GetFrame() {
|
||||
|
||||
CefRefPtr<CefV8Value> CefV8ContextImpl::GetGlobal() {
|
||||
CEF_REQUIRE_UI_THREAD(NULL);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(NULL);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Context::Scope context_scope(GetHandle());
|
||||
@ -539,6 +720,8 @@ CefRefPtr<CefV8Value> CefV8ContextImpl::GetGlobal() {
|
||||
|
||||
bool CefV8ContextImpl::Enter() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
|
||||
GetHandle()->Enter();
|
||||
#ifndef NDEBUG
|
||||
++enter_count_;
|
||||
@ -548,6 +731,8 @@ bool CefV8ContextImpl::Enter() {
|
||||
|
||||
bool CefV8ContextImpl::Exit() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
|
||||
DLOG_ASSERT(enter_count_ > 0);
|
||||
GetHandle()->Exit();
|
||||
#ifndef NDEBUG
|
||||
@ -558,6 +743,7 @@ bool CefV8ContextImpl::Exit() {
|
||||
|
||||
bool CefV8ContextImpl::IsSame(CefRefPtr<CefV8Context> that) {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
|
||||
@ -575,6 +761,7 @@ bool CefV8ContextImpl::Eval(const CefString& code,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefRefPtr<CefV8Exception>& exception) {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
|
||||
if (code.empty()) {
|
||||
NOTREACHED() << "invalid input parameter";
|
||||
@ -633,12 +820,21 @@ WebKit::WebFrame* CefV8ContextImpl::GetWebFrame() {
|
||||
// CefV8ValueImpl::Handle
|
||||
|
||||
CefV8ValueImpl::Handle::~Handle() {
|
||||
if (tracker_) {
|
||||
TrackAdd(tracker_);
|
||||
handle_.MakeWeak(tracker_, TrackDestructor);
|
||||
// Persist the |tracker_| object (call MakeWeak) if:
|
||||
// A. The value represents an Object or Function, and
|
||||
// B. The handle has been passed into a V8 function or used as a return value
|
||||
// from a V8 callback, and
|
||||
// C. The associated context, if any, is still valid.
|
||||
if (tracker_ && tracker_should_persist_
|
||||
&& (!context_state_.get() || context_state_->IsValid())) {
|
||||
handle_.MakeWeak(new CefV8MakeWeakParam(context_state_, tracker_),
|
||||
TrackDestructor);
|
||||
} else {
|
||||
handle_.Dispose();
|
||||
handle_.Clear();
|
||||
|
||||
if (tracker_)
|
||||
delete tracker_;
|
||||
}
|
||||
tracker_ = NULL;
|
||||
}
|
||||
@ -820,122 +1016,145 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(
|
||||
|
||||
CefV8ValueImpl::CefV8ValueImpl(v8::Handle<v8::Value> value,
|
||||
CefTrackNode* tracker)
|
||||
: handle_(new Handle(value, tracker)),
|
||||
: handle_(new Handle(v8::Handle<v8::Context>(), value, tracker)),
|
||||
rethrow_exceptions_(false) {
|
||||
}
|
||||
|
||||
CefV8ValueImpl::~CefV8ValueImpl() {
|
||||
}
|
||||
|
||||
|
||||
bool CefV8ValueImpl::IsValid() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return handle_->IsValid();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsUndefined() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsUndefined();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsUndefined();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsNull() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsNull();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsNull();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsBool() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return (GetHandle()->IsBoolean() || GetHandle()->IsTrue()
|
||||
|| GetHandle()->IsFalse());
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return (GetHandle(false)->IsBoolean() || GetHandle(false)->IsTrue() ||
|
||||
GetHandle(false)->IsFalse());
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsInt() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsInt32();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsInt32();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsUInt() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsUint32();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsUint32();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsDouble() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsNumber();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsNumber();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsDate() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsDate();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsDate();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsString() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsString();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsString();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsObject() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsObject();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsObject();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsArray() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsArray();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsArray();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsFunction() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return GetHandle()->IsFunction();
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
return GetHandle(false)->IsFunction();
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::IsSame(CefRefPtr<CefV8Value> that) {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
|
||||
v8::Handle<v8::Value> thatHandle;
|
||||
v8::Handle<v8::Value> thisHandle = GetHandle();
|
||||
v8::Handle<v8::Value> thisHandle = GetHandle(false);
|
||||
|
||||
CefV8ValueImpl* impl = static_cast<CefV8ValueImpl*>(that.get());
|
||||
if (impl)
|
||||
thatHandle = impl->GetHandle();
|
||||
thatHandle = impl->GetHandle(false);
|
||||
|
||||
return (thisHandle == thatHandle);
|
||||
}
|
||||
|
||||
bool CefV8ValueImpl::GetBoolValue() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
if (GetHandle()->IsTrue()) {
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
if (GetHandle(false)->IsTrue()) {
|
||||
return true;
|
||||
} else if (GetHandle()->IsFalse()) {
|
||||
} else if (GetHandle(false)->IsFalse()) {
|
||||
return false;
|
||||
} else {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Boolean> val = GetHandle()->ToBoolean();
|
||||
v8::Local<v8::Boolean> val = GetHandle(false)->ToBoolean();
|
||||
return val->Value();
|
||||
}
|
||||
}
|
||||
|
||||
int32 CefV8ValueImpl::GetIntValue() {
|
||||
CEF_REQUIRE_UI_THREAD(0);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0);
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Int32> val = GetHandle()->ToInt32();
|
||||
v8::Local<v8::Int32> val = GetHandle(false)->ToInt32();
|
||||
return val->Value();
|
||||
}
|
||||
|
||||
uint32 CefV8ValueImpl::GetUIntValue() {
|
||||
CEF_REQUIRE_UI_THREAD(0);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0);
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Uint32> val = GetHandle()->ToUint32();
|
||||
v8::Local<v8::Uint32> val = GetHandle(false)->ToUint32();
|
||||
return val->Value();
|
||||
}
|
||||
|
||||
double CefV8ValueImpl::GetDoubleValue() {
|
||||
CEF_REQUIRE_UI_THREAD(0.);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0.);
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Number> val = GetHandle()->ToNumber();
|
||||
v8::Local<v8::Number> val = GetHandle(false)->ToNumber();
|
||||
return val->Value();
|
||||
}
|
||||
|
||||
CefTime CefV8ValueImpl::GetDateValue() {
|
||||
CEF_REQUIRE_UI_THREAD(CefTime(0.));
|
||||
CEF_V8_REQUIRE_VALID_RETURN(CefTime(0.));
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Number> val = GetHandle()->ToNumber();
|
||||
v8::Local<v8::Number> val = GetHandle(false)->ToNumber();
|
||||
// Convert from milliseconds to seconds.
|
||||
return CefTime(val->Value() / 1000);
|
||||
}
|
||||
@ -943,8 +1162,9 @@ CefTime CefV8ValueImpl::GetDateValue() {
|
||||
CefString CefV8ValueImpl::GetStringValue() {
|
||||
CefString rv;
|
||||
CEF_REQUIRE_UI_THREAD(rv);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(rv);
|
||||
v8::HandleScope handle_scope;
|
||||
GetCefString(GetHandle()->ToString(), rv);
|
||||
GetCefString(GetHandle(false)->ToString(), rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -953,7 +1173,7 @@ bool CefV8ValueImpl::IsUserCreated() {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
return (tracker != NULL);
|
||||
@ -1001,7 +1221,7 @@ bool CefV8ValueImpl::HasValue(const CefString& key) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
return obj->Has(GetV8String(key));
|
||||
}
|
||||
|
||||
@ -1015,7 +1235,7 @@ bool CefV8ValueImpl::HasValue(int index) {
|
||||
}
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
return obj->Has(index);
|
||||
}
|
||||
|
||||
@ -1024,7 +1244,7 @@ bool CefV8ValueImpl::DeleteValue(const CefString& key) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
@ -1042,7 +1262,7 @@ bool CefV8ValueImpl::DeleteValue(int index) {
|
||||
}
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
@ -1055,7 +1275,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(const CefString& key) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(NULL);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
@ -1075,7 +1295,7 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::GetValue(int index) {
|
||||
}
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
@ -1094,11 +1314,11 @@ bool CefV8ValueImpl::SetValue(const CefString& key,
|
||||
CefV8ValueImpl* impl = static_cast<CefV8ValueImpl*>(value.get());
|
||||
if (impl) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(GetV8String(key), impl->GetHandle(),
|
||||
bool set = obj->Set(GetV8String(key), impl->GetHandle(true),
|
||||
static_cast<v8::PropertyAttribute>(attribute));
|
||||
return (!HasCaught(try_catch) && set);
|
||||
} else {
|
||||
@ -1119,11 +1339,11 @@ bool CefV8ValueImpl::SetValue(int index, CefRefPtr<CefV8Value> value) {
|
||||
CefV8ValueImpl* impl = static_cast<CefV8ValueImpl*>(value.get());
|
||||
if (impl) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
v8::TryCatch try_catch;
|
||||
try_catch.SetVerbose(true);
|
||||
bool set = obj->Set(index, impl->GetHandle());
|
||||
bool set = obj->Set(index, impl->GetHandle(true));
|
||||
return (!HasCaught(try_catch) && set);
|
||||
} else {
|
||||
NOTREACHED() << "invalid input parameter";
|
||||
@ -1137,7 +1357,7 @@ bool CefV8ValueImpl::SetValue(const CefString& key, AccessControl settings,
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
CefRefPtr<CefV8Accessor> accessorPtr;
|
||||
|
||||
@ -1166,7 +1386,7 @@ bool CefV8ValueImpl::GetKeys(std::vector<CefString>& keys) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
v8::Local<v8::Array> arr_keys = obj->GetPropertyNames();
|
||||
uint32_t len = arr_keys->Length();
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
@ -1183,7 +1403,7 @@ bool CefV8ValueImpl::SetUserData(CefRefPtr<CefBase> user_data) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(false);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
if (tracker) {
|
||||
@ -1199,7 +1419,7 @@ CefRefPtr<CefBase> CefV8ValueImpl::GetUserData() {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(NULL);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
if (tracker)
|
||||
@ -1213,7 +1433,7 @@ int CefV8ValueImpl::GetExternallyAllocatedMemory() {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(0);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
if (tracker)
|
||||
@ -1227,7 +1447,7 @@ int CefV8ValueImpl::AdjustExternallyAllocatedMemory(int change_in_bytes) {
|
||||
CEF_V8_REQUIRE_OBJECT_RETURN(0);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
if (tracker)
|
||||
@ -1241,7 +1461,7 @@ int CefV8ValueImpl::GetArrayLength() {
|
||||
CEF_V8_REQUIRE_ARRAY_RETURN(0);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(obj);
|
||||
return arr->Length();
|
||||
}
|
||||
@ -1252,7 +1472,7 @@ CefString CefV8ValueImpl::GetFunctionName() {
|
||||
CEF_V8_REQUIRE_FUNCTION_RETURN(rv);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(obj);
|
||||
GetCefString(v8::Handle<v8::String>::Cast(func->GetName()), rv);
|
||||
return rv;
|
||||
@ -1263,7 +1483,7 @@ CefRefPtr<CefV8Handler> CefV8ValueImpl::GetFunctionHandler() {
|
||||
CEF_V8_REQUIRE_FUNCTION_RETURN(NULL);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
|
||||
V8TrackObject* tracker = V8TrackObject::Unwrap(obj);
|
||||
if (tracker)
|
||||
@ -1300,14 +1520,14 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::ExecuteFunctionWithContext(
|
||||
|
||||
v8::Context::Scope context_scope(context_local);
|
||||
|
||||
v8::Local<v8::Object> obj = GetHandle()->ToObject();
|
||||
v8::Local<v8::Object> obj = GetHandle(false)->ToObject();
|
||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(obj);
|
||||
v8::Handle<v8::Object> recv;
|
||||
|
||||
// Default to the global object if no object or a non-object was provided.
|
||||
if (object.get() && object->IsObject()) {
|
||||
CefV8ValueImpl* recv_impl = static_cast<CefV8ValueImpl*>(object.get());
|
||||
recv = v8::Handle<v8::Object>::Cast(recv_impl->GetHandle());
|
||||
recv = v8::Handle<v8::Object>::Cast(recv_impl->GetHandle(true));
|
||||
} else {
|
||||
recv = context_local->Global();
|
||||
}
|
||||
@ -1316,8 +1536,10 @@ CefRefPtr<CefV8Value> CefV8ValueImpl::ExecuteFunctionWithContext(
|
||||
v8::Handle<v8::Value> *argv = NULL;
|
||||
if (argc > 0) {
|
||||
argv = new v8::Handle<v8::Value>[argc];
|
||||
for (int i = 0; i < argc; ++i)
|
||||
argv[i] = static_cast<CefV8ValueImpl*>(arguments[i].get())->GetHandle();
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
argv[i] =
|
||||
static_cast<CefV8ValueImpl*>(arguments[i].get())->GetHandle(true);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
@ -1367,6 +1589,7 @@ CefRefPtr<CefV8StackTrace> CefV8StackTrace::GetCurrent(int frame_limit) {
|
||||
CEF_REQUIRE_VALID_CONTEXT(NULL);
|
||||
CEF_REQUIRE_UI_THREAD(NULL);
|
||||
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Handle<v8::StackTrace> stackTrace =
|
||||
v8::StackTrace::CurrentStackTrace(
|
||||
frame_limit, v8::StackTrace::kDetailed);
|
||||
@ -1379,20 +1602,27 @@ CefRefPtr<CefV8StackTrace> CefV8StackTrace::GetCurrent(int frame_limit) {
|
||||
// CefV8StackTraceImpl
|
||||
|
||||
CefV8StackTraceImpl::CefV8StackTraceImpl(v8::Handle<v8::StackTrace> handle)
|
||||
: handle_(new Handle(handle)) {
|
||||
: handle_(new Handle(v8::Handle<v8::Context>(), handle)) {
|
||||
}
|
||||
|
||||
CefV8StackTraceImpl::~CefV8StackTraceImpl() {
|
||||
}
|
||||
|
||||
bool CefV8StackTraceImpl::IsValid() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return handle_->IsValid();
|
||||
}
|
||||
|
||||
int CefV8StackTraceImpl::GetFrameCount() {
|
||||
CEF_REQUIRE_UI_THREAD(0);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0);
|
||||
v8::HandleScope handle_scope;
|
||||
return GetHandle()->GetFrameCount();
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8StackFrame> CefV8StackTraceImpl::GetFrame(int index) {
|
||||
CEF_REQUIRE_UI_THREAD(NULL);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(NULL);
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Handle<v8::StackFrame> stackFrame = GetHandle()->GetFrame(index);
|
||||
if (stackFrame.IsEmpty())
|
||||
@ -1404,15 +1634,21 @@ CefRefPtr<CefV8StackFrame> CefV8StackTraceImpl::GetFrame(int index) {
|
||||
// CefV8StackFrameImpl
|
||||
|
||||
CefV8StackFrameImpl::CefV8StackFrameImpl(v8::Handle<v8::StackFrame> handle)
|
||||
: handle_(new Handle(handle)) {
|
||||
: handle_(new Handle(v8::Handle<v8::Context>(), handle)) {
|
||||
}
|
||||
|
||||
CefV8StackFrameImpl::~CefV8StackFrameImpl() {
|
||||
}
|
||||
|
||||
bool CefV8StackFrameImpl::IsValid() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
return handle_->IsValid();
|
||||
}
|
||||
|
||||
CefString CefV8StackFrameImpl::GetScriptName() {
|
||||
CefString rv;
|
||||
CEF_REQUIRE_UI_THREAD(rv);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(rv);
|
||||
v8::HandleScope handle_scope;
|
||||
GetCefString(v8::Handle<v8::String>::Cast(GetHandle()->GetScriptName()), rv);
|
||||
return rv;
|
||||
@ -1421,6 +1657,7 @@ CefString CefV8StackFrameImpl::GetScriptName() {
|
||||
CefString CefV8StackFrameImpl::GetScriptNameOrSourceURL() {
|
||||
CefString rv;
|
||||
CEF_REQUIRE_UI_THREAD(rv);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(rv);
|
||||
v8::HandleScope handle_scope;
|
||||
GetCefString(
|
||||
v8::Handle<v8::String>::Cast(GetHandle()->GetScriptNameOrSourceURL()),
|
||||
@ -1431,6 +1668,7 @@ CefString CefV8StackFrameImpl::GetScriptNameOrSourceURL() {
|
||||
CefString CefV8StackFrameImpl::GetFunctionName() {
|
||||
CefString rv;
|
||||
CEF_REQUIRE_UI_THREAD(rv);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(rv);
|
||||
v8::HandleScope handle_scope;
|
||||
GetCefString(
|
||||
v8::Handle<v8::String>::Cast(GetHandle()->GetFunctionName()), rv);
|
||||
@ -1439,24 +1677,28 @@ CefString CefV8StackFrameImpl::GetFunctionName() {
|
||||
|
||||
int CefV8StackFrameImpl::GetLineNumber() {
|
||||
CEF_REQUIRE_UI_THREAD(0);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0);
|
||||
v8::HandleScope handle_scope;
|
||||
return GetHandle()->GetLineNumber();
|
||||
}
|
||||
|
||||
int CefV8StackFrameImpl::GetColumn() {
|
||||
CEF_REQUIRE_UI_THREAD(0);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(0);
|
||||
v8::HandleScope handle_scope;
|
||||
return GetHandle()->GetColumn();
|
||||
}
|
||||
|
||||
bool CefV8StackFrameImpl::IsEval() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
v8::HandleScope handle_scope;
|
||||
return GetHandle()->IsEval();
|
||||
}
|
||||
|
||||
bool CefV8StackFrameImpl::IsConstructor() {
|
||||
CEF_REQUIRE_UI_THREAD(false);
|
||||
CEF_V8_REQUIRE_VALID_RETURN(false);
|
||||
v8::HandleScope handle_scope;
|
||||
return GetHandle()->IsConstructor();
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "include/cef_v8.h"
|
||||
#include "v8/include/v8.h"
|
||||
#include "libcef/cef_thread.h"
|
||||
#include "libcef/tracker.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefTrackNode;
|
||||
@ -19,25 +20,80 @@ namespace WebKit {
|
||||
class WebFrame;
|
||||
};
|
||||
|
||||
// Call to detach all handles associated with the specified contxt.
|
||||
void CefV8ReleaseContext(v8::Handle<v8::Context> context);
|
||||
|
||||
// Used to detach handles when the associated context is released.
|
||||
class CefV8ContextState : public base::RefCounted<CefV8ContextState> {
|
||||
public:
|
||||
CefV8ContextState() : valid_(true) {}
|
||||
virtual ~CefV8ContextState() {}
|
||||
|
||||
bool IsValid() { return valid_; }
|
||||
void Detach() {
|
||||
DCHECK(valid_);
|
||||
valid_ = false;
|
||||
track_manager_.DeleteAll();
|
||||
}
|
||||
|
||||
void AddTrackObject(CefTrackNode* object) {
|
||||
DCHECK(valid_);
|
||||
track_manager_.Add(object);
|
||||
}
|
||||
|
||||
void DeleteTrackObject(CefTrackNode* object) {
|
||||
DCHECK(valid_);
|
||||
track_manager_.Delete(object);
|
||||
}
|
||||
|
||||
private:
|
||||
bool valid_;
|
||||
CefTrackManager track_manager_;
|
||||
};
|
||||
|
||||
// Base class for V8 Handle types.
|
||||
class CefV8HandleBase :
|
||||
public base::RefCountedThreadSafe<CefV8HandleBase,
|
||||
CefThread::DeleteOnUIThread> {
|
||||
public:
|
||||
virtual ~CefV8HandleBase() {}
|
||||
|
||||
// Returns true if there is no underlying context or if the underlying context
|
||||
// is valid.
|
||||
bool IsValid() {
|
||||
return (!context_state_.get() || context_state_->IsValid());
|
||||
}
|
||||
|
||||
protected:
|
||||
// |context| is the context that owns this handle. If empty the current
|
||||
// context will be used.
|
||||
explicit CefV8HandleBase(v8::Handle<v8::Context> context);
|
||||
|
||||
protected:
|
||||
scoped_refptr<CefV8ContextState> context_state_;
|
||||
};
|
||||
|
||||
// Template for V8 Handle types. This class is used to ensure that V8 objects
|
||||
// are only released on the UI thread.
|
||||
template <typename v8class>
|
||||
class CefV8Handle :
|
||||
public base::RefCountedThreadSafe<CefV8Handle<v8class>,
|
||||
CefThread::DeleteOnUIThread> {
|
||||
class CefV8Handle : public CefV8HandleBase {
|
||||
public:
|
||||
typedef v8::Handle<v8class> handleType;
|
||||
typedef v8::Persistent<v8class> persistentType;
|
||||
|
||||
CefV8Handle(handleType v)
|
||||
: handle_(persistentType::New(v)) {
|
||||
CefV8Handle(v8::Handle<v8::Context> context, handleType v)
|
||||
: CefV8HandleBase(context),
|
||||
handle_(persistentType::New(v)) {
|
||||
}
|
||||
~CefV8Handle() {
|
||||
virtual ~CefV8Handle() {
|
||||
handle_.Dispose();
|
||||
handle_.Clear();
|
||||
}
|
||||
|
||||
handleType GetHandle() { return handle_; }
|
||||
handleType GetHandle() {
|
||||
DCHECK(IsValid());
|
||||
return handle_;
|
||||
}
|
||||
|
||||
protected:
|
||||
persistentType handle_;
|
||||
@ -57,6 +113,7 @@ class CefV8ContextImpl : public CefV8Context {
|
||||
explicit CefV8ContextImpl(v8::Handle<v8::Context> context);
|
||||
virtual ~CefV8ContextImpl();
|
||||
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual CefRefPtr<CefFrame> GetFrame() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8Value> GetGlobal() OVERRIDE;
|
||||
@ -90,6 +147,7 @@ class CefV8ValueImpl : public CefV8Value {
|
||||
CefV8ValueImpl(v8::Handle<v8::Value> value, CefTrackNode* tracker = NULL);
|
||||
virtual ~CefV8ValueImpl();
|
||||
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual bool IsUndefined() OVERRIDE;
|
||||
virtual bool IsNull() OVERRIDE;
|
||||
virtual bool IsBool() OVERRIDE;
|
||||
@ -141,25 +199,33 @@ class CefV8ValueImpl : public CefV8Value {
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments) OVERRIDE;
|
||||
|
||||
v8::Handle<v8::Value> GetHandle() { return handle_->GetHandle(); }
|
||||
v8::Handle<v8::Value> GetHandle(bool should_persist) {
|
||||
return handle_->GetHandle(should_persist);
|
||||
}
|
||||
|
||||
protected:
|
||||
// Test for and record any exception.
|
||||
bool HasCaught(v8::TryCatch& try_catch);
|
||||
|
||||
class Handle :
|
||||
public base::RefCountedThreadSafe<Handle, CefThread::DeleteOnUIThread> {
|
||||
class Handle : public CefV8HandleBase {
|
||||
public:
|
||||
typedef v8::Handle<v8::Value> handleType;
|
||||
typedef v8::Persistent<v8::Value> persistentType;
|
||||
|
||||
Handle(handleType v, CefTrackNode* tracker)
|
||||
: handle_(persistentType::New(v)),
|
||||
tracker_(tracker) {
|
||||
Handle(v8::Handle<v8::Context> context, handleType v, CefTrackNode* tracker)
|
||||
: CefV8HandleBase(context),
|
||||
handle_(persistentType::New(v)),
|
||||
tracker_(tracker),
|
||||
tracker_should_persist_(false) {
|
||||
}
|
||||
~Handle();
|
||||
virtual ~Handle();
|
||||
|
||||
handleType GetHandle() { return handle_; }
|
||||
handleType GetHandle(bool should_persist) {
|
||||
DCHECK(IsValid());
|
||||
if (should_persist && tracker_ && !tracker_should_persist_)
|
||||
tracker_should_persist_ = true;
|
||||
return handle_;
|
||||
}
|
||||
|
||||
private:
|
||||
persistentType handle_;
|
||||
@ -168,6 +234,10 @@ class CefV8ValueImpl : public CefV8Value {
|
||||
// internal data or function handler objects that are reference counted.
|
||||
CefTrackNode* tracker_;
|
||||
|
||||
// True if the |tracker_| object needs to persist due to an Object or
|
||||
// Function type being passed into V8.
|
||||
bool tracker_should_persist_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Handle);
|
||||
};
|
||||
scoped_refptr<Handle> handle_;
|
||||
@ -184,6 +254,7 @@ class CefV8StackTraceImpl : public CefV8StackTrace {
|
||||
explicit CefV8StackTraceImpl(v8::Handle<v8::StackTrace> handle);
|
||||
virtual ~CefV8StackTraceImpl();
|
||||
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual int GetFrameCount() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8StackFrame> GetFrame(int index) OVERRIDE;
|
||||
|
||||
@ -202,6 +273,7 @@ class CefV8StackFrameImpl : public CefV8StackFrame {
|
||||
explicit CefV8StackFrameImpl(v8::Handle<v8::StackFrame> handle);
|
||||
virtual ~CefV8StackFrameImpl();
|
||||
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual CefString GetScriptName() OVERRIDE;
|
||||
virtual CefString GetScriptNameOrSourceURL() OVERRIDE;
|
||||
virtual CefString GetFunctionName() OVERRIDE;
|
||||
|
@ -52,6 +52,20 @@ CEF_EXPORT int cef_v8context_in_context() {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK v8context_is_valid(struct _cef_v8context_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefV8ContextCppToC::Get(self)->IsValid();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_browser_t* CEF_CALLBACK v8context_get_browser(
|
||||
struct _cef_v8context_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -212,6 +226,7 @@ int CEF_CALLBACK v8context_eval(struct _cef_v8context_t* self,
|
||||
|
||||
CefV8ContextCppToC::CefV8ContextCppToC(CefV8Context* cls)
|
||||
: CefCppToC<CefV8ContextCppToC, CefV8Context, cef_v8context_t>(cls) {
|
||||
struct_.struct_.is_valid = v8context_is_valid;
|
||||
struct_.struct_.get_browser = v8context_get_browser;
|
||||
struct_.struct_.get_frame = v8context_get_frame;
|
||||
struct_.struct_.get_global = v8context_get_global;
|
||||
|
@ -15,6 +15,20 @@
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK v8stack_frame_is_valid(struct _cef_v8stack_frame_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefV8StackFrameCppToC::Get(self)->IsValid();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
cef_string_userfree_t CEF_CALLBACK v8stack_frame_get_script_name(
|
||||
struct _cef_v8stack_frame_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -125,6 +139,7 @@ int CEF_CALLBACK v8stack_frame_is_constructor(
|
||||
CefV8StackFrameCppToC::CefV8StackFrameCppToC(CefV8StackFrame* cls)
|
||||
: CefCppToC<CefV8StackFrameCppToC, CefV8StackFrame, cef_v8stack_frame_t>(
|
||||
cls) {
|
||||
struct_.struct_.is_valid = v8stack_frame_is_valid;
|
||||
struct_.struct_.get_script_name = v8stack_frame_get_script_name;
|
||||
struct_.struct_.get_script_name_or_source_url =
|
||||
v8stack_frame_get_script_name_or_source_url;
|
||||
|
@ -30,6 +30,20 @@ CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit) {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK v8stack_trace_is_valid(struct _cef_v8stack_trace_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefV8StackTraceCppToC::Get(self)->IsValid();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8stack_trace_get_frame_count(
|
||||
struct _cef_v8stack_trace_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -68,6 +82,7 @@ struct _cef_v8stack_frame_t* CEF_CALLBACK v8stack_trace_get_frame(
|
||||
CefV8StackTraceCppToC::CefV8StackTraceCppToC(CefV8StackTrace* cls)
|
||||
: CefCppToC<CefV8StackTraceCppToC, CefV8StackTrace, cef_v8stack_trace_t>(
|
||||
cls) {
|
||||
struct_.struct_.is_valid = v8stack_trace_is_valid;
|
||||
struct_.struct_.get_frame_count = v8stack_trace_get_frame_count;
|
||||
struct_.struct_.get_frame = v8stack_trace_get_frame;
|
||||
}
|
||||
|
@ -167,6 +167,20 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name,
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
int CEF_CALLBACK v8value_is_valid(struct _cef_v8value_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return 0;
|
||||
|
||||
// Execute
|
||||
bool _retval = CefV8ValueCppToC::Get(self)->IsValid();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
int CEF_CALLBACK v8value_is_undefined(struct _cef_v8value_t* self) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
@ -903,6 +917,7 @@ struct _cef_v8value_t* CEF_CALLBACK v8value_execute_function_with_context(
|
||||
|
||||
CefV8ValueCppToC::CefV8ValueCppToC(CefV8Value* cls)
|
||||
: CefCppToC<CefV8ValueCppToC, CefV8Value, cef_v8value_t>(cls) {
|
||||
struct_.struct_.is_valid = v8value_is_valid;
|
||||
struct_.struct_.is_undefined = v8value_is_undefined;
|
||||
struct_.struct_.is_null = v8value_is_null;
|
||||
struct_.struct_.is_bool = v8value_is_bool;
|
||||
|
@ -52,6 +52,19 @@ bool CefV8Context::InContext() {
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefV8ContextCToCpp::IsValid() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_valid(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefV8ContextCToCpp::GetBrowser() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_browser))
|
||||
return NULL;
|
||||
|
@ -32,6 +32,7 @@ class CefV8ContextCToCpp
|
||||
virtual ~CefV8ContextCToCpp() {}
|
||||
|
||||
// CefV8Context methods
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual CefRefPtr<CefFrame> GetFrame() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8Value> GetGlobal() OVERRIDE;
|
||||
|
@ -15,6 +15,19 @@
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefV8StackFrameCToCpp::IsValid() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_valid(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefString CefV8StackFrameCToCpp::GetScriptName() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_script_name))
|
||||
return CefString();
|
||||
|
@ -34,6 +34,7 @@ class CefV8StackFrameCToCpp
|
||||
virtual ~CefV8StackFrameCToCpp() {}
|
||||
|
||||
// CefV8StackFrame methods
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual CefString GetScriptName() OVERRIDE;
|
||||
virtual CefString GetScriptNameOrSourceURL() OVERRIDE;
|
||||
virtual CefString GetFunctionName() OVERRIDE;
|
||||
|
@ -30,6 +30,19 @@ CefRefPtr<CefV8StackTrace> CefV8StackTrace::GetCurrent(int frame_limit) {
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefV8StackTraceCToCpp::IsValid() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_valid(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
int CefV8StackTraceCToCpp::GetFrameCount() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_frame_count))
|
||||
return 0;
|
||||
|
@ -34,6 +34,7 @@ class CefV8StackTraceCToCpp
|
||||
virtual ~CefV8StackTraceCToCpp() {}
|
||||
|
||||
// CefV8StackTrace methods
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual int GetFrameCount() OVERRIDE;
|
||||
virtual CefRefPtr<CefV8StackFrame> GetFrame(int index) OVERRIDE;
|
||||
};
|
||||
|
@ -159,6 +159,19 @@ CefRefPtr<CefV8Value> CefV8Value::CreateFunction(const CefString& name,
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefV8ValueCToCpp::IsValid() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_valid))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_valid(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefV8ValueCToCpp::IsUndefined() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_undefined))
|
||||
return false;
|
||||
|
@ -33,6 +33,7 @@ class CefV8ValueCToCpp
|
||||
virtual ~CefV8ValueCToCpp() {}
|
||||
|
||||
// CefV8Value methods
|
||||
virtual bool IsValid() OVERRIDE;
|
||||
virtual bool IsUndefined() OVERRIDE;
|
||||
virtual bool IsNull() OVERRIDE;
|
||||
virtual bool IsBool() OVERRIDE;
|
||||
|
@ -259,6 +259,8 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
|
||||
g_command_line->HasSwitch(cefclient::kPackLoadingDisabled);
|
||||
settings.uncaught_exception_stack_size = GetIntValue(
|
||||
g_command_line->GetSwitchValue(cefclient::kUncaughtExceptionStackSize));
|
||||
settings.context_safety_implementation = GetIntValue(
|
||||
g_command_line->GetSwitchValue(cefclient::kContextSafetyImplementation));
|
||||
|
||||
// Retrieve command-line proxy configuration, if any.
|
||||
bool has_proxy = false;
|
||||
|
@ -37,7 +37,7 @@ IDS_XMLHTTPREQUEST BINARY "res\\xmlhttprequest.html"
|
||||
IDS_DOMACCESS BINARY "res\\domaccess.html"
|
||||
IDS_MODALMAIN BINARY "res\\modalmain.html"
|
||||
IDS_MODALDIALOG BINARY "res\\modaldialog.html"
|
||||
IDS_EXTENSIONPERF BINARY "res\\extensionperf.html"
|
||||
IDS_PERFORMANCE BINARY "res\\performance.html"
|
||||
IDS_TRANSPARENCY BINARY "res\\transparency.html"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -75,9 +75,9 @@ BEGIN
|
||||
MENUITEM "Get Text", ID_TESTS_GETTEXT
|
||||
MENUITEM "JavaScript Binding Handler", ID_TESTS_JAVASCRIPT_BINDING
|
||||
MENUITEM "JavaScript Extension Handler",ID_TESTS_JAVASCRIPT_EXTENSION
|
||||
MENUITEM "JavaScript Extension Performance",ID_TESTS_JAVASCRIPT_PERFORMANCE
|
||||
MENUITEM "JavaScript Execute", ID_TESTS_JAVASCRIPT_EXECUTE
|
||||
MENUITEM "JavaScript Invoke", ID_TESTS_JAVASCRIPT_INVOKE
|
||||
MENUITEM "Performance Tests", ID_TESTS_PERFORMANCE
|
||||
MENUITEM "Plugin", ID_TESTS_PLUGIN
|
||||
MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO
|
||||
MENUITEM "Popup Window", ID_TESTS_POPUP
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "cefclient/binding_test.h"
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/extension_test.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
@ -70,6 +71,14 @@ gboolean JSExecuteActivated(GtkWidget* widget) {
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > Performance Tests... menu item.
|
||||
gboolean PerformanceActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
performance_test::RunTest(g_handler->GetBrowser());
|
||||
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
|
||||
// Callback for Debug > Request... menu item.
|
||||
gboolean RequestActivated(GtkWidget* widget) {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
@ -280,6 +289,8 @@ GtkWidget* CreateMenuBar() {
|
||||
G_CALLBACK(JSExtensionActivated));
|
||||
AddMenuEntry(debug_menu, "JS Execute",
|
||||
G_CALLBACK(JSExecuteActivated));
|
||||
AddMenuEntry(debug_menu, "Performance Tests",
|
||||
G_CALLBACK(PerformanceActivated));
|
||||
AddMenuEntry(debug_menu, "Request",
|
||||
G_CALLBACK(RequestActivated));
|
||||
AddMenuEntry(debug_menu, "Local Storage",
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/extension_test.h"
|
||||
#include "cefclient/osrtest_mac.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
@ -192,9 +193,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
- (IBAction)testGetText:(id)sender;
|
||||
- (IBAction)testJSBinding:(id)sender;
|
||||
- (IBAction)testJSExtension:(id)sender;
|
||||
- (IBAction)testJSExtensionPerf:(id)sender;
|
||||
- (IBAction)testJSExecute:(id)sender;
|
||||
- (IBAction)testJSInvoke:(id)sender;
|
||||
- (IBAction)testPerformance:(id)sender;
|
||||
- (IBAction)testRequest:(id)sender;
|
||||
- (IBAction)testLocalStorage:(id)sender;
|
||||
- (IBAction)testXMLHttpRequest:(id)sender;
|
||||
@ -245,15 +246,15 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
[testMenu addItemWithTitle:@"JavaScript Extension Handler"
|
||||
action:@selector(testJSExtension:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"JavaScript Extension Performance"
|
||||
action:@selector(testJSExtensionPerf:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"JavaScript Execute"
|
||||
action:@selector(testJSExecute:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"JavaScript Invoke"
|
||||
action:@selector(testJSInvoke:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"Performance Tests"
|
||||
action:@selector(testPerformance:)
|
||||
keyEquivalent:@""];
|
||||
[testMenu addItemWithTitle:@"Popup Window"
|
||||
action:@selector(testPopupWindow:)
|
||||
keyEquivalent:@""];
|
||||
@ -425,11 +426,6 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
RunExtensionTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testJSExtensionPerf:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunExtensionPerfTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testJSExecute:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunJavaScriptExecuteTest(g_handler->GetBrowser());
|
||||
@ -440,6 +436,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
RunJavaScriptInvokeTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testPerformance:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
performance_test::RunTest(g_handler->GetBrowser());
|
||||
}
|
||||
|
||||
- (IBAction)testRequest:(id)sender {
|
||||
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
||||
RunRequestTest(g_handler->GetBrowser());
|
||||
|
@ -36,6 +36,7 @@ const char kResourcesDirPath[] = "resources-dir-path";
|
||||
const char kLocalesDirPath[] = "locales-dir-path";
|
||||
const char kPackLoadingDisabled[] = "pack-loading-disabled";
|
||||
const char kUncaughtExceptionStackSize[] = "uncaught-exception-stack-size";
|
||||
const char kContextSafetyImplementation[] = "context-safety-implementation";
|
||||
|
||||
// CefBrowserSettings attributes.
|
||||
const char kDragDropDisabled[] = "drag-drop-disabled";
|
||||
|
@ -38,6 +38,7 @@ extern const char kResourcesDirPath[];
|
||||
extern const char kLocalesDirPath[];
|
||||
extern const char kPackLoadingDisabled[];
|
||||
extern const char kUncaughtExceptionStackSize[];
|
||||
extern const char kContextSafetyImplementation[];
|
||||
|
||||
// CefBrowserSettings attributes.
|
||||
extern const char kDragDropDisabled[];
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "cefclient/extension_test.h"
|
||||
#include "cefclient/osrplugin_test.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/plugin_test.h"
|
||||
#include "cefclient/resource.h"
|
||||
#include "cefclient/scheme_test.h"
|
||||
@ -448,10 +449,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
if (browser.get())
|
||||
RunExtensionTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_JAVASCRIPT_PERFORMANCE: // Test the V8 performance
|
||||
if (browser.get())
|
||||
RunExtensionPerfTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_JAVASCRIPT_EXECUTE: // Test execution of javascript
|
||||
if (browser.get())
|
||||
RunJavaScriptExecuteTest(browser);
|
||||
@ -460,6 +457,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
if (browser.get())
|
||||
RunJavaScriptInvokeTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_PERFORMANCE: // Run performance tests
|
||||
if (browser.get())
|
||||
performance_test::RunTest(browser);
|
||||
return 0;
|
||||
case ID_TESTS_PLUGIN: // Test the custom plugin
|
||||
if (browser.get())
|
||||
RunPluginTest(browser);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "cefclient/cefclient.h"
|
||||
#include "cefclient/cefclient_switches.h"
|
||||
#include "cefclient/download_handler.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
ClientHandler::ClientHandler()
|
||||
@ -262,8 +263,14 @@ void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
||||
|
||||
// Add the V8 bindings.
|
||||
InitBindingTest(browser, frame, context->GetGlobal());
|
||||
InitBindingTest(browser, frame, object);
|
||||
|
||||
std::string url = frame->GetURL();
|
||||
if (url == performance_test::kTestUrl)
|
||||
performance_test::InitTest(browser, frame, object);
|
||||
}
|
||||
|
||||
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "cefclient/client_handler.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
@ -61,6 +62,10 @@ bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
resourceStream = GetBinaryResourceReader("domaccess.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
} else if (url == performance_test::kTestUrl) {
|
||||
resourceStream = GetBinaryResourceReader("performance.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "cefclient/cefclient.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/string_util.h"
|
||||
|
||||
@ -75,6 +76,10 @@ bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
resourceStream = GetBinaryResourceReader("domaccess.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
} else if (url == performance_test::kTestUrl) {
|
||||
resourceStream = GetBinaryResourceReader("performance.html");
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <string>
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/resource.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/string_util.h"
|
||||
@ -115,6 +116,10 @@ bool ClientHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
|
||||
html.size());
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
} else if (url == performance_test::kTestUrl) {
|
||||
resourceStream = GetBinaryResourceReader(IDS_PERFORMANCE);
|
||||
response->SetMimeType("text/html");
|
||||
response->SetStatus(200);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -23,10 +23,7 @@ class ClientV8ExtensionHandler : public CefV8Handler {
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
if (name == "Dummy") {
|
||||
// Used for performance testing.
|
||||
return true;
|
||||
} else if (name == "SetTestParam") {
|
||||
if (name == "SetTestParam") {
|
||||
// Handle the SetTestParam native function by saving the string argument
|
||||
// into the local member.
|
||||
if (arguments.size() != 1 || !arguments[0]->IsString())
|
||||
@ -89,10 +86,6 @@ void InitExtensionTest() {
|
||||
" native function GetTestObject();"
|
||||
" return GetTestObject();"
|
||||
" };"
|
||||
" cef.test.dummy = function() {"
|
||||
" native function Dummy();"
|
||||
" return Dummy();"
|
||||
" };"
|
||||
"})();";
|
||||
CefRegisterExtension("v8/test", code, new ClientV8ExtensionHandler());
|
||||
}
|
||||
@ -114,13 +107,3 @@ void RunExtensionTest(CefRefPtr<CefBrowser> browser) {
|
||||
"</pre></body></html>";
|
||||
browser->GetMainFrame()->LoadString(html, "about:blank");
|
||||
}
|
||||
|
||||
void RunExtensionPerfTest(CefRefPtr<CefBrowser> browser) {
|
||||
CefRefPtr<CefStreamReader> resourceStream;
|
||||
#if defined(OS_WIN)
|
||||
resourceStream = GetBinaryResourceReader(IDS_EXTENSIONPERF);
|
||||
#elif defined(OS_MACOSX)
|
||||
resourceStream = GetBinaryResourceReader("extensionperf.html");
|
||||
#endif
|
||||
browser->GetMainFrame()->LoadStream(resourceStream, "about:blank");
|
||||
}
|
||||
|
@ -15,6 +15,5 @@ void InitExtensionTest();
|
||||
|
||||
// Run the test.
|
||||
void RunExtensionTest(CefRefPtr<CefBrowser> browser);
|
||||
void RunExtensionPerfTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_EXTENSION_TEST_H_
|
||||
|
104
cef1/tests/cefclient/performance_test.cpp
Normal file
104
cef1/tests/cefclient/performance_test.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "include/cef_v8.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "cefclient/performance_test_setup.h"
|
||||
#include "cefclient/resource_util.h"
|
||||
|
||||
namespace performance_test {
|
||||
|
||||
// Use more interations for a Release build.
|
||||
#ifdef NDEBUG
|
||||
const size_t kDefaultIterations = 100000;
|
||||
#else
|
||||
const size_t kDefaultIterations = 10000;
|
||||
#endif
|
||||
|
||||
const char kTestUrl[] = "http://tests/performance";
|
||||
|
||||
namespace {
|
||||
|
||||
const char kGetPerfTests[] = "GetPerfTests";
|
||||
const char kRunPerfTest[] = "RunPerfTest";
|
||||
|
||||
class V8Handler : public CefV8Handler {
|
||||
public:
|
||||
V8Handler() {
|
||||
}
|
||||
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
if (name == kRunPerfTest) {
|
||||
if (arguments.size() == 1 && arguments[0]->IsString()) {
|
||||
// Run the specified perf test.
|
||||
bool found = false;
|
||||
|
||||
std::string test = arguments[0]->GetStringValue();
|
||||
for (size_t i = 0; i < kPerfTestsCount; ++i) {
|
||||
if (test == kPerfTests[i].name) {
|
||||
// Execute the test.
|
||||
int64 delta = kPerfTests[i].test(kPerfTests[i].iterations);
|
||||
|
||||
retval = CefV8Value::CreateInt(delta);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
std::string msg = "Unknown test: ";
|
||||
msg.append(test);
|
||||
exception = msg;
|
||||
}
|
||||
} else {
|
||||
exception = "Invalid function parameters";
|
||||
}
|
||||
} else if (name == kGetPerfTests) {
|
||||
// Retrieve the list of perf tests.
|
||||
retval = CefV8Value::CreateArray(kPerfTestsCount);
|
||||
for (size_t i = 0; i < kPerfTestsCount; ++i) {
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateArray(2);
|
||||
val->SetValue(0, CefV8Value::CreateString(kPerfTests[i].name));
|
||||
val->SetValue(1, CefV8Value::CreateUInt(kPerfTests[i].iterations));
|
||||
retval->SetValue(i, val);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(V8Handler);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void InitTest(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object) {
|
||||
CefRefPtr<CefV8Handler> handler = new V8Handler();
|
||||
|
||||
// Bind test functions.
|
||||
object->SetValue(kGetPerfTests,
|
||||
CefV8Value::CreateFunction(kGetPerfTests, handler),
|
||||
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||
object->SetValue(kRunPerfTest,
|
||||
CefV8Value::CreateFunction(kRunPerfTest, handler),
|
||||
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||
}
|
||||
|
||||
void RunTest(CefRefPtr<CefBrowser> browser) {
|
||||
// Load the test URL.
|
||||
browser->GetMainFrame()->LoadURL(kTestUrl);
|
||||
}
|
||||
|
||||
} // namespace performance_test
|
28
cef1/tests/cefclient/performance_test.h
Normal file
28
cef1/tests/cefclient/performance_test.h
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_
|
||||
#define CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
|
||||
class CefBrowser;
|
||||
class CefFrame;
|
||||
class CefV8Value;
|
||||
|
||||
namespace performance_test {
|
||||
|
||||
extern const char kTestUrl[];
|
||||
|
||||
void InitTest(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Value> object);
|
||||
|
||||
// Run the test.
|
||||
void RunTest(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
} // namespace performance_test
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_
|
99
cef1/tests/cefclient/performance_test_setup.h
Normal file
99
cef1/tests/cefclient/performance_test_setup.h
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_SETUP_H_
|
||||
#define CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_SETUP_H_
|
||||
#pragma once
|
||||
|
||||
#include "cefclient/util.h"
|
||||
|
||||
namespace performance_test {
|
||||
|
||||
// Default number of iterations.
|
||||
extern const size_t kDefaultIterations;
|
||||
|
||||
// Test name.
|
||||
#define PERF_TEST_NAME(name) PerfTest##name
|
||||
|
||||
// Entry in test array.
|
||||
#define PERF_TEST_ENTRY_EX(name, iterations) \
|
||||
{ #name, PERF_TEST_NAME(name), iterations }
|
||||
#define PERF_TEST_ENTRY(name) PERF_TEST_ENTRY_EX(name, kDefaultIterations)
|
||||
|
||||
// Test function declaration.
|
||||
#define PERF_TEST_RESULT int64
|
||||
#define PERF_TEST_PARAM_ITERATIONS iterations
|
||||
#define PERF_TEST_PARAMS size_t PERF_TEST_PARAM_ITERATIONS
|
||||
#define PERF_TEST_FUNC(name) \
|
||||
PERF_TEST_RESULT PERF_TEST_NAME(name)(PERF_TEST_PARAMS)
|
||||
|
||||
// Typedef for test pointers.
|
||||
typedef PERF_TEST_RESULT(PerfTest(PERF_TEST_PARAMS));
|
||||
|
||||
class CefTimer {
|
||||
public:
|
||||
CefTimer() : running_(false) {
|
||||
}
|
||||
|
||||
bool IsRunning() { return running_; }
|
||||
|
||||
void Start() {
|
||||
ASSERT(!running_);
|
||||
running_ = true;
|
||||
start_.Now();
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
stop_.Now();
|
||||
ASSERT(running_);
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
int64 Delta() {
|
||||
ASSERT(!running_);
|
||||
return start_.Delta(stop_);
|
||||
}
|
||||
|
||||
private:
|
||||
bool running_;
|
||||
CefTime start_;
|
||||
CefTime stop_;
|
||||
};
|
||||
|
||||
// Peform test iterations using a user-provided timing result variable.
|
||||
#define PERF_ITERATIONS_START_EX() \
|
||||
{ \
|
||||
CefTimer _timer; \
|
||||
_timer.Start(); \
|
||||
for (size_t _i = 0; _i < PERF_TEST_PARAM_ITERATIONS; ++_i) {
|
||||
|
||||
#define PERF_ITERATIONS_END_EX(result) \
|
||||
} \
|
||||
_timer.Stop(); \
|
||||
result = _timer.Delta(); \
|
||||
}
|
||||
|
||||
// Perform test iterations and return the timing result.
|
||||
#define PERF_ITERATIONS_START() \
|
||||
int64 _result = 0; \
|
||||
PERF_ITERATIONS_START_EX()
|
||||
|
||||
#define PERF_ITERATIONS_END() \
|
||||
PERF_ITERATIONS_END_EX(_result) \
|
||||
return _result;
|
||||
|
||||
// Perf test entry structure.
|
||||
struct PerfTestEntry {
|
||||
const char* name;
|
||||
PerfTest* test;
|
||||
size_t iterations;
|
||||
};
|
||||
|
||||
// Array of perf tests.
|
||||
extern const PerfTestEntry kPerfTests[];
|
||||
extern const size_t kPerfTestsCount;
|
||||
|
||||
} // namespace performance_test
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_H_
|
328
cef1/tests/cefclient/performance_test_tests.cpp
Normal file
328
cef1/tests/cefclient/performance_test_tests.cpp
Normal file
@ -0,0 +1,328 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/performance_test.h"
|
||||
#include "cefclient/performance_test_setup.h"
|
||||
#include "include/cef_v8.h"
|
||||
|
||||
namespace performance_test {
|
||||
|
||||
namespace {
|
||||
|
||||
// Test function implementations.
|
||||
|
||||
PERF_TEST_FUNC(V8NullCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateNull();
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8BoolCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateBool(true);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8IntCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateInt(-5);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8UIntCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateUInt(10);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8DoubleCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateDouble(12.432);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8DateCreate) {
|
||||
static cef_time_t time = {2012, 1, 0, 1};
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(time);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8StringCreate) {
|
||||
CefString str = "test string";
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateString(str);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ArrayCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateArray(1);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ArraySetValue) {
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray(1);
|
||||
array->SetValue(0, val);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
array->SetValue(0, val);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ArrayGetValue) {
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray(1);
|
||||
array->SetValue(0, val);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> ret = array->GetValue(0);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8FunctionCreate) {
|
||||
class Handler : public CefV8Handler {
|
||||
public:
|
||||
Handler() {}
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE { return false; }
|
||||
IMPLEMENT_REFCOUNTING(Handler);
|
||||
};
|
||||
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateFunction(name, handler);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8FunctionExecute) {
|
||||
class Handler : public CefV8Handler {
|
||||
public:
|
||||
Handler() {}
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE { return true; }
|
||||
IMPLEMENT_REFCOUNTING(Handler);
|
||||
};
|
||||
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(name, handler);
|
||||
CefRefPtr<CefV8Value> obj = CefV8Context::GetCurrentContext()->GetGlobal();
|
||||
CefV8ValueList args;
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
func->ExecuteFunction(obj, args);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8FunctionExecuteWithContext) {
|
||||
class Handler : public CefV8Handler {
|
||||
public:
|
||||
Handler() {}
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE { return true; }
|
||||
IMPLEMENT_REFCOUNTING(Handler);
|
||||
};
|
||||
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(name, handler);
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
CefRefPtr<CefV8Value> obj = context->GetGlobal();
|
||||
CefV8ValueList args;
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
func->ExecuteFunctionWithContext(context, obj, args);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectCreate) {
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(NULL);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectCreateWithAccessor) {
|
||||
class Accessor : public CefV8Accessor {
|
||||
public:
|
||||
Accessor() {}
|
||||
virtual bool Get(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
virtual bool Set(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value,
|
||||
CefString& exception) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
IMPLEMENT_REFCOUNTING(Accessor);
|
||||
};
|
||||
|
||||
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(accessor);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectSetValue) {
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(NULL);
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectGetValue) {
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(NULL);
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> ret = obj->GetValue(name);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectSetValueWithAccessor) {
|
||||
class Accessor : public CefV8Accessor {
|
||||
public:
|
||||
Accessor() {}
|
||||
virtual bool Get(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
virtual bool Set(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value,
|
||||
CefString& exception) OVERRIDE {
|
||||
val_ = value;
|
||||
return true;
|
||||
}
|
||||
CefRefPtr<CefV8Value> val_;
|
||||
IMPLEMENT_REFCOUNTING(Accessor);
|
||||
};
|
||||
|
||||
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(accessor);
|
||||
obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ObjectGetValueWithAccessor) {
|
||||
class Accessor : public CefV8Accessor {
|
||||
public:
|
||||
Accessor() : val_(CefV8Value::CreateBool(true)) {}
|
||||
virtual bool Get(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE {
|
||||
retval = val_;
|
||||
return true;
|
||||
}
|
||||
virtual bool Set(const CefString& name,
|
||||
const CefRefPtr<CefV8Value> object,
|
||||
const CefRefPtr<CefV8Value> value,
|
||||
CefString& exception) OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
CefRefPtr<CefV8Value> val_;
|
||||
IMPLEMENT_REFCOUNTING(Accessor);
|
||||
};
|
||||
|
||||
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||
|
||||
CefString name = "name";
|
||||
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(accessor);
|
||||
obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
CefRefPtr<CefV8Value> ret = obj->GetValue(name);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ContextEnterExit) {
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
context->Enter();
|
||||
context->Exit();
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
PERF_TEST_FUNC(V8ContextEval) {
|
||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||
CefString jsCode = "var i = 0;";
|
||||
CefRefPtr<CefV8Value> retval;
|
||||
CefRefPtr<CefV8Exception> exception;
|
||||
|
||||
PERF_ITERATIONS_START()
|
||||
context->Eval(jsCode, retval, exception);
|
||||
PERF_ITERATIONS_END()
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
// Test function entries.
|
||||
|
||||
const PerfTestEntry kPerfTests[] = {
|
||||
PERF_TEST_ENTRY(V8NullCreate),
|
||||
PERF_TEST_ENTRY(V8BoolCreate),
|
||||
PERF_TEST_ENTRY(V8IntCreate),
|
||||
PERF_TEST_ENTRY(V8UIntCreate),
|
||||
PERF_TEST_ENTRY(V8DoubleCreate),
|
||||
PERF_TEST_ENTRY(V8DateCreate),
|
||||
PERF_TEST_ENTRY(V8StringCreate),
|
||||
PERF_TEST_ENTRY(V8ArrayCreate),
|
||||
PERF_TEST_ENTRY(V8ArraySetValue),
|
||||
PERF_TEST_ENTRY(V8ArrayGetValue),
|
||||
PERF_TEST_ENTRY(V8FunctionCreate),
|
||||
PERF_TEST_ENTRY(V8FunctionExecute),
|
||||
PERF_TEST_ENTRY(V8FunctionExecuteWithContext),
|
||||
PERF_TEST_ENTRY(V8ObjectCreate),
|
||||
PERF_TEST_ENTRY(V8ObjectCreateWithAccessor),
|
||||
PERF_TEST_ENTRY(V8ObjectSetValue),
|
||||
PERF_TEST_ENTRY(V8ObjectGetValue),
|
||||
PERF_TEST_ENTRY(V8ObjectSetValueWithAccessor),
|
||||
PERF_TEST_ENTRY(V8ObjectGetValueWithAccessor),
|
||||
PERF_TEST_ENTRY(V8ContextEnterExit),
|
||||
PERF_TEST_ENTRY(V8ContextEval),
|
||||
};
|
||||
|
||||
const size_t kPerfTestsCount = (sizeof(kPerfTests) / sizeof(kPerfTests[0]));
|
||||
|
||||
} // namespace performance_test
|
@ -1,131 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>JavaScript Extension: Performance</title>
|
||||
<style>
|
||||
body { font-family: Tahoma, Serif; font-size: 9pt; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>JavaScript Extension: Performance</h1>
|
||||
|
||||
<div><span id="statusBox"></span> <progress id="progressBox" value="0" style="display:none"></progress></div>
|
||||
|
||||
<div style="padding-top:10px; padding-bottom:10px">
|
||||
<table id="resultTable" border="1" cellspacing="1" cellpadding="4" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Min</td>
|
||||
<td>Avg</td>
|
||||
<td>Max</td>
|
||||
<td>Probes</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- result rows here -->
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var asyncExecution = true;
|
||||
var testIterations = 100000;
|
||||
var totalProbes = 10;
|
||||
var probeDelay = 0;
|
||||
|
||||
var collectProbes = false;
|
||||
|
||||
function dummyCallTest() {
|
||||
for (var i = 0; i < testIterations; i++) {
|
||||
cef.test.dummy();
|
||||
}
|
||||
}
|
||||
|
||||
function execTestFunc(func) {
|
||||
var begin = new Date();
|
||||
func();
|
||||
var end = new Date();
|
||||
return (end - begin);
|
||||
}
|
||||
|
||||
function execTest(test) {
|
||||
function nextStep() {
|
||||
if (asyncExecution) {
|
||||
setTimeout(function () { execTest(test); }, probeDelay);
|
||||
} else {
|
||||
execTest(test);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
appendResult(test);
|
||||
// ...
|
||||
}
|
||||
|
||||
updateStatus(test);
|
||||
if (!test.warmedUp) {
|
||||
execTestFunc(test.func);
|
||||
test.warmedUp = true;
|
||||
return nextStep();
|
||||
}
|
||||
|
||||
if (test.probe >= test.totalProbes) {
|
||||
test.avg = test.total / test.totalProbes;
|
||||
return nextTest();
|
||||
}
|
||||
|
||||
var elapsed = execTestFunc(test.func);
|
||||
test.total += elapsed;
|
||||
if (!test.min) test.min = elapsed;
|
||||
else if (test.min > elapsed) test.min = elapsed;
|
||||
if (!test.max) test.max = elapsed;
|
||||
else if (test.max < elapsed) test.max = elapsed;
|
||||
if (collectProbes) {
|
||||
test.results.push(elapsed);
|
||||
}
|
||||
test.probe++;
|
||||
|
||||
return nextStep();
|
||||
}
|
||||
|
||||
function updateStatus(test) {
|
||||
var statusBox = document.getElementById("statusBox");
|
||||
var progressBox = document.getElementById("progressBox");
|
||||
|
||||
if (test.probe >= test.totalProbes) {
|
||||
statusBox.innerText = test.name + " completed.";
|
||||
progressBox.style.display = 'none';
|
||||
} else {
|
||||
statusBox.innerText = test.name + " (" + test.probe + "/" + test.totalProbes + ")";
|
||||
progressBox.value = (test.probe / test.totalProbes);
|
||||
progressBox.style.display = 'inline';
|
||||
}
|
||||
}
|
||||
|
||||
function appendResult(test) {
|
||||
var e = document.getElementById("resultTable");
|
||||
|
||||
e.insertAdjacentHTML("beforeEnd",
|
||||
["<tr>",
|
||||
"<td>", test.name, "</td>",
|
||||
"<td>", test.min, "ms</td>",
|
||||
"<td>", test.avg, "ms</td>",
|
||||
"<td>", test.max, "ms</td>",
|
||||
"<td>", test.results.join(", "), "</td>",
|
||||
"<tr>"
|
||||
].join("")
|
||||
);
|
||||
}
|
||||
|
||||
function runTest(name, func) {
|
||||
var test = { name: name, func: func, warmedUp: false, total: 0, totalProbes: totalProbes, probe: 0, results: [] };
|
||||
setTimeout(function () { execTest(test); }, 10);
|
||||
}
|
||||
|
||||
runTest("dummyCall", dummyCallTest);
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
293
cef1/tests/cefclient/res/performance.html
Normal file
293
cef1/tests/cefclient/res/performance.html
Normal file
@ -0,0 +1,293 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Performance Tests</title>
|
||||
<style>
|
||||
body { font-family: Tahoma, Serif; font-size: 9pt; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Performance Tests</h1>
|
||||
<input type="button" value="Run Tests" onClick="run();" id="run"/> Filter: <input type="text" size="50" id="filters"/>
|
||||
<div><span id="statusBox"></span> <progress id="progressBox" value="0" style="display:none"></progress></div>
|
||||
|
||||
<div style="padding-top:10px; padding-bottom:10px">
|
||||
<table id="resultTable" border="1" cellspacing="1" cellpadding="4">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Iterations per Run</td>
|
||||
<td>Avg (ms)</td>
|
||||
<td>Min (ms)</td>
|
||||
<td>Max (ms)</td>
|
||||
<td>StdDev (ms)</td>
|
||||
<td>Runs (ms)</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- result rows here -->
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr width="80%">
|
||||
|
||||
Result 1: <input type="text" size="100" id="result1"/>
|
||||
<br/>Result 2: <input type="text" size="100" id="result2"/>
|
||||
<br/><input type="button" value="Compare" onClick="compare();" id="compare"/>
|
||||
|
||||
<div style="padding-top:10px; padding-bottom:10px">
|
||||
<table id="compareTable" border="1" cellspacing="1" cellpadding="4">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Result 1 Avg (ms)</td>
|
||||
<td>Result 2 Avg (ms)</td>
|
||||
<td>% Diff</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- result rows here -->
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function run() {
|
||||
var runElement = document.getElementById("run");
|
||||
var filtersElement = document.getElementById("filters");
|
||||
var compareElement = document.getElementById("compare");
|
||||
var result1Element = document.getElementById("result1");
|
||||
var result2Element = document.getElementById("result2");
|
||||
|
||||
// Number of runs for each test.
|
||||
var testRuns = 10;
|
||||
|
||||
// Delay between test runs.
|
||||
var runDelay = 0;
|
||||
|
||||
// Retrieve the list of all tests.
|
||||
var allTests = window.GetPerfTests();
|
||||
|
||||
// Populated with the list of tests that will be run.
|
||||
var tests = [];
|
||||
var currentTest = 0;
|
||||
|
||||
var testList = filtersElement.value.trim();
|
||||
if (testList.length > 0) {
|
||||
// Include or exclude specific tests.
|
||||
var included = [];
|
||||
var excluded = [];
|
||||
|
||||
var testNames = testList.split(",");
|
||||
|
||||
// Identify included and excluded tests.
|
||||
for (i = 0; i < testNames.length; ++i) {
|
||||
var testName = testNames[i].trim();
|
||||
if (testName[0] == '-') {
|
||||
// Exclude the test.
|
||||
excluded.push(testName.substr(1));
|
||||
} else {
|
||||
// Include the test.
|
||||
included.push(testName);
|
||||
}
|
||||
}
|
||||
|
||||
if (included.length > 0) {
|
||||
// Only use the included tests.
|
||||
for (i = 0; i < allTests.length; ++i) {
|
||||
var test = allTests[i];
|
||||
var testName = test[0];
|
||||
if (included.indexOf(testName) >= 0)
|
||||
tests.push(test);
|
||||
}
|
||||
} else if (excluded.length > 0) {
|
||||
// Use all tests except the excluded tests.
|
||||
for (i = 0; i < allTests.length; ++i) {
|
||||
var test = allTests[i];
|
||||
var testName = test[0];
|
||||
if (excluded.indexOf(testName) < 0)
|
||||
tests.push(test);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Run all tests.
|
||||
tests = allTests;
|
||||
}
|
||||
|
||||
function updateStatusComplete() {
|
||||
var statusBox = document.getElementById("statusBox");
|
||||
statusBox.innerText = 'All tests completed.';
|
||||
|
||||
runElement.disabled = false;
|
||||
filtersElement.disabled = false;
|
||||
result1Element.disabled = false;
|
||||
result2Element.disabled = false;
|
||||
compareElement.disabled = false;
|
||||
}
|
||||
|
||||
function updateStatus(test) {
|
||||
var statusBox = document.getElementById("statusBox");
|
||||
var progressBox = document.getElementById("progressBox");
|
||||
|
||||
if (test.run >= test.totalRuns) {
|
||||
statusBox.innerText = test.name + " completed.";
|
||||
progressBox.style.display = 'none';
|
||||
} else {
|
||||
statusBox.innerText = test.name + " (" + test.run + "/" + test.totalRuns + ")";
|
||||
progressBox.value = (test.run / test.totalRuns);
|
||||
progressBox.style.display = 'inline';
|
||||
}
|
||||
}
|
||||
|
||||
function appendResult(test) {
|
||||
var e = document.getElementById("resultTable");
|
||||
|
||||
// Calculate the average.
|
||||
var avg = test.total / test.totalRuns;
|
||||
|
||||
// Calculate the standard deviation.
|
||||
var sqsum = 0;
|
||||
for (i = 0; i < test.results.length; ++i) {
|
||||
var diff = test.results[i] - avg;
|
||||
sqsum += diff * diff;
|
||||
}
|
||||
var stddev = Math.round(Math.sqrt(sqsum / test.totalRuns) * 100.0) / 100.0;
|
||||
|
||||
e.insertAdjacentHTML("beforeEnd", [
|
||||
"<tr>",
|
||||
"<td>", test.name, "</td>",
|
||||
"<td>", test.iterations, "</td>",
|
||||
"<td>", avg, "</td>",
|
||||
"<td>", test.min, "</td>",
|
||||
"<td>", test.max, "</td>",
|
||||
"<td>", stddev, "</td>",
|
||||
"<td>", test.results.join(", "), "</td>",
|
||||
"<tr>"
|
||||
].join(""));
|
||||
|
||||
if (result1Element.value.length > 0)
|
||||
result1Element.value += ",";
|
||||
result1Element.value += test.name + "=" + avg;
|
||||
}
|
||||
|
||||
// Execute the test function.
|
||||
function execTestFunc(name) {
|
||||
return window.RunPerfTest(name);
|
||||
}
|
||||
|
||||
// Schedule the next test.
|
||||
function nextTest(test) {
|
||||
appendResult(test);
|
||||
currentTest++;
|
||||
runTest();
|
||||
}
|
||||
|
||||
// Schedule the next step for the current test.
|
||||
function nextTestStep(test) {
|
||||
setTimeout(function () { execTest(test); }, runDelay);
|
||||
}
|
||||
|
||||
// Perform the next step for the current test.
|
||||
function execTest(test) {
|
||||
updateStatus(test);
|
||||
|
||||
if (!test.warmedUp) {
|
||||
execTestFunc(test.name);
|
||||
test.warmedUp = true;
|
||||
return nextTestStep(test);
|
||||
}
|
||||
|
||||
if (test.run >= test.totalRuns)
|
||||
return nextTest(test);
|
||||
|
||||
var elapsed = execTestFunc(test.name);
|
||||
test.results.push(elapsed);
|
||||
|
||||
test.total += elapsed;
|
||||
if (!test.min) test.min = elapsed;
|
||||
else if (test.min > elapsed) test.min = elapsed;
|
||||
if (!test.max) test.max = elapsed;
|
||||
else if (test.max < elapsed) test.max = elapsed;
|
||||
|
||||
test.run++;
|
||||
|
||||
return nextTestStep(test);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
if (currentTest == tests.length) {
|
||||
updateStatusComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = {
|
||||
name: tests[currentTest][0],
|
||||
iterations: tests[currentTest][1],
|
||||
warmedUp: false,
|
||||
total: 0,
|
||||
totalRuns: testRuns,
|
||||
run: 0,
|
||||
results: []
|
||||
};
|
||||
setTimeout(function () { execTest(test); }, runDelay);
|
||||
}
|
||||
|
||||
// Schedule the first test.
|
||||
if (tests.length > 0) {
|
||||
runElement.disabled = true;
|
||||
filtersElement.disabled = true;
|
||||
result1Element.value = "";
|
||||
result1Element.disabled = true;
|
||||
result2Element.disabled = true;
|
||||
compareElement.disabled = true;
|
||||
|
||||
runTest();
|
||||
}
|
||||
}
|
||||
|
||||
function compare() {
|
||||
var result1 = document.getElementById("result1").value.trim();
|
||||
var result2 = document.getElementById("result2").value.trim();
|
||||
|
||||
if (result1.length == 0 || result2.length == 0)
|
||||
return;
|
||||
|
||||
var r1values = result1.split(",");
|
||||
var r2values = result2.split(",");
|
||||
for (i = 0; i < r1values.length; ++i) {
|
||||
var r1parts = r1values[i].split("=");
|
||||
var r1name = r1parts[0].trim();
|
||||
var r1val = r1parts[1].trim();
|
||||
|
||||
for (x = 0; x < r2values.length; ++x) {
|
||||
var r2parts = r2values[x].split("=");
|
||||
var r2name = r2parts[0].trim();
|
||||
var r2val = r2parts[1].trim();
|
||||
|
||||
if (r2name == r1name) {
|
||||
appendResult(r1name, r1val, r2val);
|
||||
|
||||
// Remove the matching index.
|
||||
r2values.splice(x, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function appendResult(name, r1val, r2val) {
|
||||
var e = document.getElementById("compareTable");
|
||||
|
||||
// Calculate the percent difference.
|
||||
var diff = Math.round(((r2val - r1val) / r1val) * 10000.0) / 100.0;
|
||||
|
||||
e.insertAdjacentHTML("beforeEnd", [
|
||||
"<tr>",
|
||||
"<td>", name, "</td>",
|
||||
"<td>", r1val, "</td>",
|
||||
"<td>", r2val, "</td>",
|
||||
"<td>", diff, "</td>",
|
||||
"<tr>"
|
||||
].join(""));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -51,7 +51,7 @@
|
||||
#define ID_TESTS_DRAGDROP 32792
|
||||
#define ID_TESTS_OSRAPP 32793
|
||||
#define ID_TESTS_MODALDIALOG 32794
|
||||
#define ID_TESTS_JAVASCRIPT_PERFORMANCE 32795
|
||||
#define ID_TESTS_PERFORMANCE 32795
|
||||
#define ID_TESTS_TRANSPARENT_POPUP 32796
|
||||
#define ID_TESTS_TRANSPARENT_OSRAPP 32797
|
||||
#define ID_TESTS_JAVASCRIPT_INVOKE 32798
|
||||
@ -68,7 +68,7 @@
|
||||
#define IDS_OSRPLUGIN 1006
|
||||
#define IDS_MODALMAIN 1007
|
||||
#define IDS_MODALDIALOG 1008
|
||||
#define IDS_EXTENSIONPERF 1009
|
||||
#define IDS_PERFORMANCE 1009
|
||||
#define IDS_TRANSPARENCY 1010
|
||||
|
||||
// Avoid files associated with MacOS
|
||||
|
@ -3,6 +3,9 @@
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "tests/unittests/test_suite.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "tests/cefclient/cefclient_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
@ -16,6 +19,18 @@
|
||||
#include "base/test/test_timeouts.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// Return the int representation of the specified string.
|
||||
int GetIntValue(const std::string& str) {
|
||||
if (str.empty())
|
||||
return 0;
|
||||
|
||||
return atoi(str.c_str());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CommandLine* CefTestSuite::commandline_ = NULL;
|
||||
|
||||
CefTestSuite::CefTestSuite(int argc, char** argv)
|
||||
@ -127,6 +142,10 @@ void CefTestSuite::GetSettings(CefSettings& settings) {
|
||||
|
||||
// Necessary for V8Test.OnUncaughtException tests.
|
||||
settings.uncaught_exception_stack_size = 10;
|
||||
|
||||
settings.context_safety_implementation = GetIntValue(
|
||||
commandline_->GetSwitchValueASCII(
|
||||
cefclient::kContextSafetyImplementation));
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -18,12 +18,13 @@
|
||||
namespace {
|
||||
|
||||
// Unique values for V8 tests.
|
||||
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* kV8OnUncaughtExceptionTestUrl =
|
||||
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 kV8OnUncaughtExceptionTestUrl[] =
|
||||
"http://tests/V8Test.OnUncaughtException";
|
||||
const char kV8NavTestUrl[] = "http://tests/V8Test.NavTest";
|
||||
|
||||
enum V8TestMode {
|
||||
V8TEST_NULL_CREATE = 0,
|
||||
@ -57,6 +58,7 @@ enum V8TestMode {
|
||||
V8TEST_CONTEXT_EVAL,
|
||||
V8TEST_CONTEXT_EVAL_EXCEPTION,
|
||||
V8TEST_CONTEXT_ENTERED,
|
||||
V8TEST_CONTEXT_INVALID,
|
||||
V8TEST_BINDING,
|
||||
V8TEST_STACK_TRACE,
|
||||
V8TEST_ON_UNCAUGHT_EXCEPTION,
|
||||
@ -73,11 +75,14 @@ class V8TestHandler : public TestHandler {
|
||||
}
|
||||
|
||||
virtual void RunTest() OVERRIDE {
|
||||
// Nested script tag forces creation of the V8 context.
|
||||
if (test_mode_ == V8TEST_CONTEXT_ENTERED) {
|
||||
AddResource(kV8ContextParentTestUrl, "<html><body><iframe src=\"" +
|
||||
AddResource(kV8ContextParentTestUrl, "<html><body>"
|
||||
"<script>var i = 0;</script><iframe src=\"" +
|
||||
std::string(kV8ContextChildTestUrl) + "\" id=\"f\"></iframe></body>"
|
||||
"</html>", "text/html");
|
||||
AddResource(kV8ContextChildTestUrl, "<html><body>CHILD</body></html>",
|
||||
AddResource(kV8ContextChildTestUrl, "<html><body>"
|
||||
"<script>var i = 0;</script>CHILD</body></html>",
|
||||
"text/html");
|
||||
CreateBrowser(kV8ContextParentTestUrl);
|
||||
} else if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
||||
@ -92,8 +97,14 @@ class V8TestHandler : public TestHandler {
|
||||
"text/html");
|
||||
CreateBrowser(kV8OnUncaughtExceptionTestUrl);
|
||||
} else {
|
||||
if (test_mode_ == V8TEST_CONTEXT_INVALID) {
|
||||
AddResource(kV8NavTestUrl, "<html><body>"
|
||||
"<script>var i = 0;</script>TEST</body></html>", "text/html");
|
||||
}
|
||||
|
||||
EXPECT_TRUE(test_url_ != NULL);
|
||||
AddResource(test_url_, "<html><body>TEST</body></html>", "text/html");
|
||||
AddResource(test_url_, "<html><body>"
|
||||
"<script>var i = 0;</script>TEST</body></html>", "text/html");
|
||||
CreateBrowser(test_url_);
|
||||
}
|
||||
}
|
||||
@ -194,6 +205,10 @@ class V8TestHandler : public TestHandler {
|
||||
case V8TEST_CONTEXT_ENTERED:
|
||||
RunContextEnteredTest();
|
||||
break;
|
||||
case V8TEST_CONTEXT_INVALID:
|
||||
// The test is triggered when the context is released.
|
||||
GetBrowser()->GetMainFrame()->LoadURL(kV8NavTestUrl);
|
||||
break;
|
||||
case V8TEST_BINDING:
|
||||
RunBindingTest();
|
||||
break;
|
||||
@ -1545,14 +1560,14 @@ class V8TestHandler : public TestHandler {
|
||||
}
|
||||
|
||||
void RunOnUncaughtExceptionTest() {
|
||||
on_uncaught_exception_context_ =
|
||||
test_context_ =
|
||||
GetBrowser()->GetMainFrame()->GetV8Context();
|
||||
GetBrowser()->GetMainFrame()->ExecuteJavaScript("test()",
|
||||
CefString(), 0);
|
||||
}
|
||||
|
||||
void RunOnUncaughtExceptionDevToolsTest() {
|
||||
on_uncaught_exception_context_ =
|
||||
test_context_ =
|
||||
GetBrowser()->GetMainFrame()->GetV8Context();
|
||||
GetBrowser()->ShowDevTools();
|
||||
}
|
||||
@ -1566,7 +1581,7 @@ class V8TestHandler : public TestHandler {
|
||||
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
||||
test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
EXPECT_TRUE(on_uncaught_exception_context_->IsSame(context));
|
||||
EXPECT_TRUE(test_context_->IsSame(context));
|
||||
EXPECT_STREQ("Uncaught ReferenceError: asd is not defined",
|
||||
exception->GetMessage().ToString().c_str());
|
||||
std::ostringstream stackFormatted;
|
||||
@ -1587,7 +1602,8 @@ class V8TestHandler : public TestHandler {
|
||||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode) OVERRIDE {
|
||||
if (frame->IsMain())
|
||||
std::string url = frame->GetURL();
|
||||
if (frame->IsMain() && url != kV8NavTestUrl)
|
||||
RunTest(test_mode_);
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS &&
|
||||
browser->IsPopup()) {
|
||||
@ -1654,8 +1670,25 @@ class V8TestHandler : public TestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
std::string url = frame->GetURL();
|
||||
if (test_mode_ == V8TEST_CONTEXT_INVALID && url == test_url_) {
|
||||
test_context_ = context;
|
||||
test_object_ = CefV8Value::CreateArray(10);
|
||||
CefPostTask(TID_UI,
|
||||
NewCefRunnableMethod(this, &V8TestHandler::DestroyTest));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DestroyTest() OVERRIDE {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
||||
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());
|
||||
} else if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION ||
|
||||
test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
EXPECT_TRUE(got_on_uncaught_exception_);
|
||||
}
|
||||
@ -1674,7 +1707,8 @@ class V8TestHandler : public TestHandler {
|
||||
|
||||
V8TestMode test_mode_;
|
||||
const char* test_url_;
|
||||
CefRefPtr<CefV8Context> on_uncaught_exception_context_;
|
||||
CefRefPtr<CefV8Context> test_context_;
|
||||
CefRefPtr<CefV8Value> test_object_;
|
||||
|
||||
TrackCallback got_destroy_test_;
|
||||
TrackCallback got_on_uncaught_exception_;
|
||||
@ -1728,6 +1762,7 @@ V8_TEST(FunctionHandlerWithContext, V8TEST_FUNCTION_HANDLER_WITH_CONTEXT);
|
||||
V8_TEST(ContextEval, V8TEST_CONTEXT_EVAL);
|
||||
V8_TEST(ContextEvalException, V8TEST_CONTEXT_EVAL_EXCEPTION);
|
||||
V8_TEST_EX(ContextEntered, V8TEST_CONTEXT_ENTERED, NULL);
|
||||
V8_TEST(ContextInvalid, V8TEST_CONTEXT_INVALID);
|
||||
V8_TEST_EX(Binding, V8TEST_BINDING, kV8BindingTestUrl);
|
||||
V8_TEST(StackTrace, V8TEST_STACK_TRACE);
|
||||
V8_TEST(OnUncaughtException, V8TEST_ON_UNCAUGHT_EXCEPTION);
|
||||
|
Loading…
x
Reference in New Issue
Block a user