Remove V8 worker bindings (issue #451).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1209 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
9a34a5d5da
commit
0ffaf01b5b
|
@ -132,39 +132,6 @@ typedef struct _cef_render_process_handler_t {
|
|||
struct _cef_v8context_t* context, struct _cef_v8exception_t* exception,
|
||||
struct _cef_v8stack_trace_t* stackTrace);
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread immediately after the V8 context for a new
|
||||
// WebWorker has been created. To retrieve the JavaScript 'self' object use
|
||||
// the cef_v8context_t::get_global() function. V8 handles can only be accessed
|
||||
// from the thread on which they are created. A task runner for posting tasks
|
||||
// on the associated thread can be retrieved via the
|
||||
// cef_v8context_t::get_task_runner() function.
|
||||
///
|
||||
void (CEF_CALLBACK *on_worker_context_created)(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context);
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread immediately before the V8 context for a
|
||||
// WebWorker is released. No references to the context should be kept after
|
||||
// this function is called. Any tasks posted or pending on the WebWorker
|
||||
// thread after this function is called may not be executed.
|
||||
///
|
||||
void (CEF_CALLBACK *on_worker_context_released)(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context);
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread for global uncaught exceptions in a
|
||||
// WebWorker. Execution of this callback is disabled by default. To enable set
|
||||
// CefSettings.uncaught_exception_stack_size > 0.
|
||||
///
|
||||
void (CEF_CALLBACK *on_worker_uncaught_exception)(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context,
|
||||
struct _cef_v8exception_t* exception,
|
||||
struct _cef_v8stack_trace_t* stackTrace);
|
||||
|
||||
///
|
||||
// Called when a new node in the the browser gets focus. The |node| value may
|
||||
// be NULL if no specific node has gained focus. The node object passed to
|
||||
|
|
|
@ -130,43 +130,6 @@ class CefRenderProcessHandler : public virtual CefBase {
|
|||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread immediately after the V8 context for a new
|
||||
// WebWorker has been created. To retrieve the JavaScript 'self' object use
|
||||
// the CefV8Context::GetGlobal() method. V8 handles can only be accessed from
|
||||
// the thread on which they are created. A task runner for posting tasks on
|
||||
// the associated thread can be retrieved via the
|
||||
// CefV8Context::GetTaskRunner() method.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnWorkerContextCreated(int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread immediately before the V8 context for a
|
||||
// WebWorker is released. No references to the context should be kept after
|
||||
// this method is called. Any tasks posted or pending on the WebWorker
|
||||
// thread after this method is called may not be executed.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnWorkerContextReleased(int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
///
|
||||
// Called on the WebWorker thread for global uncaught exceptions in a
|
||||
// WebWorker. Execution of this callback is disabled by default. To enable set
|
||||
// CefSettings.uncaught_exception_stack_size > 0.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnWorkerUncaughtException(
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
///
|
||||
// Called when a new node in the the browser gets focus. The |node| value may
|
||||
// be empty if no specific node has gained focus. The node object passed to
|
||||
|
|
|
@ -48,7 +48,6 @@ MSVC_POP_WARNING();
|
|||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerInfo.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerScriptObserver.h"
|
||||
#include "v8/include/v8.h"
|
||||
#include "webkit/glue/worker_task_runner.h"
|
||||
|
||||
|
@ -131,79 +130,6 @@ class CefWebWorkerTaskRunner : public base::SequencedTaskRunner,
|
|||
|
||||
} // namespace
|
||||
|
||||
|
||||
class CefWebWorkerScriptObserver : public WebKit::WebWorkerScriptObserver {
|
||||
public:
|
||||
CefWebWorkerScriptObserver() {
|
||||
}
|
||||
|
||||
virtual void didCreateWorkerScriptContext(
|
||||
const WebKit::WebWorkerRunLoop& run_loop,
|
||||
const WebKit::WebURL& url,
|
||||
v8::Handle<v8::Context> context) OVERRIDE {
|
||||
// Create global objects associated with the WebWorker Isolate.
|
||||
CefV8IsolateCreated();
|
||||
|
||||
int stack_size =
|
||||
CefContentRendererClient::Get()->uncaught_exception_stack_size();
|
||||
if (stack_size > 0)
|
||||
CefV8SetUncaughtExceptionStackSize(stack_size);
|
||||
|
||||
webkit_glue::WorkerTaskRunner* worker_runner =
|
||||
webkit_glue::WorkerTaskRunner::Instance();
|
||||
int worker_id = worker_runner->CurrentWorkerId();
|
||||
DCHECK_GT(worker_id, 0);
|
||||
GURL gurl = GURL(url);
|
||||
|
||||
CefV8SetWorkerAttributes(worker_id, gurl);
|
||||
|
||||
// Notify the render process handler.
|
||||
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
||||
if (application.get()) {
|
||||
CefRefPtr<CefRenderProcessHandler> handler =
|
||||
application->GetRenderProcessHandler();
|
||||
if (handler.get()) {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
|
||||
handler->OnWorkerContextCreated(worker_id, gurl.spec(), contextPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void willReleaseWorkerScriptContext(
|
||||
const WebKit::WebWorkerRunLoop& run_loop,
|
||||
const WebKit::WebURL& url,
|
||||
v8::Handle<v8::Context> context) OVERRIDE {
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
// Notify the render process handler.
|
||||
CefRefPtr<CefApp> application = CefContentClient::Get()->application();
|
||||
if (application.get()) {
|
||||
CefRefPtr<CefRenderProcessHandler> handler =
|
||||
application->GetRenderProcessHandler();
|
||||
if (handler.get()) {
|
||||
webkit_glue::WorkerTaskRunner* worker_runner =
|
||||
webkit_glue::WorkerTaskRunner::Instance();
|
||||
int worker_id = worker_runner->CurrentWorkerId();
|
||||
DCHECK_GT(worker_id, 0);
|
||||
|
||||
CefRefPtr<CefV8Context> contextPtr(new CefV8ContextImpl(context));
|
||||
GURL gurl = GURL(url);
|
||||
handler->OnWorkerContextReleased(worker_id, gurl.spec(), contextPtr);
|
||||
}
|
||||
}
|
||||
|
||||
CefV8ReleaseContext(context);
|
||||
|
||||
// Destroy global objects associated with the WebWorker Isolate.
|
||||
CefV8IsolateDestroyed();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CefContentRendererClient::SchemeInfo {
|
||||
std::string scheme_name;
|
||||
bool is_local;
|
||||
|
@ -286,9 +212,6 @@ void CefContentRendererClient::WebKitInitialized() {
|
|||
WebKit::WebRuntimeFeatures::enableMediaStream(
|
||||
command_line.HasSwitch(switches::kEnableMediaStream));
|
||||
|
||||
worker_script_observer_.reset(new CefWebWorkerScriptObserver());
|
||||
WebKit::WebWorkerInfo::addScriptObserver(worker_script_observer_.get());
|
||||
|
||||
if (!scheme_info_list_.empty()) {
|
||||
// Register the custom schemes.
|
||||
SchemeInfoList::const_iterator it = scheme_info_list_.begin();
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "content/public/renderer/content_renderer_client.h"
|
||||
|
||||
class CefRenderProcessObserver;
|
||||
class CefWebWorkerScriptObserver;
|
||||
struct Cef_CrossOriginWhiteListEntry_Params;
|
||||
|
||||
class CefContentRendererClient : public content::ContentRendererClient,
|
||||
|
@ -103,7 +102,6 @@ class CefContentRendererClient : public content::ContentRendererClient,
|
|||
|
||||
scoped_refptr<base::SequencedTaskRunner> render_task_runner_;
|
||||
scoped_ptr<CefRenderProcessObserver> observer_;
|
||||
scoped_ptr<CefWebWorkerScriptObserver> worker_script_observer_;
|
||||
|
||||
// Map of RenderView pointers to CefBrowserImpl references.
|
||||
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl> > BrowserMap;
|
||||
|
|
|
@ -706,11 +706,6 @@ void MessageListenerCallbackImpl(v8::Handle<v8::Message> message,
|
|||
if (CEF_CURRENTLY_ON_RT()) {
|
||||
handler->OnUncaughtException(context->GetBrowser(), context->GetFrame(),
|
||||
context, exception, stackTrace);
|
||||
} else {
|
||||
CefV8IsolateManager* manager = GetIsolateManager();
|
||||
DCHECK_GT(manager->worker_id(), 0);
|
||||
handler->OnWorkerUncaughtException(manager->worker_id(),
|
||||
manager->worker_url().spec(), context, exception, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -218,90 +218,6 @@ void CEF_CALLBACK render_process_handler_on_uncaught_exception(
|
|||
CefV8StackTraceCToCpp::Wrap(stackTrace));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK render_process_handler_on_worker_context_created(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(url);
|
||||
if (!url)
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context);
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextCreated(
|
||||
worker_id,
|
||||
CefString(url),
|
||||
CefV8ContextCToCpp::Wrap(context));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK render_process_handler_on_worker_context_released(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(url);
|
||||
if (!url)
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context);
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefRenderProcessHandlerCppToC::Get(self)->OnWorkerContextReleased(
|
||||
worker_id,
|
||||
CefString(url),
|
||||
CefV8ContextCToCpp::Wrap(context));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK render_process_handler_on_worker_uncaught_exception(
|
||||
struct _cef_render_process_handler_t* self, int worker_id,
|
||||
const cef_string_t* url, struct _cef_v8context_t* context,
|
||||
struct _cef_v8exception_t* exception,
|
||||
struct _cef_v8stack_trace_t* stackTrace) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self)
|
||||
return;
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(url);
|
||||
if (!url)
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context);
|
||||
if (!context)
|
||||
return;
|
||||
// Verify param: exception; type: refptr_diff
|
||||
DCHECK(exception);
|
||||
if (!exception)
|
||||
return;
|
||||
// Verify param: stackTrace; type: refptr_diff
|
||||
DCHECK(stackTrace);
|
||||
if (!stackTrace)
|
||||
return;
|
||||
|
||||
// Execute
|
||||
CefRenderProcessHandlerCppToC::Get(self)->OnWorkerUncaughtException(
|
||||
worker_id,
|
||||
CefString(url),
|
||||
CefV8ContextCToCpp::Wrap(context),
|
||||
CefV8ExceptionCToCpp::Wrap(exception),
|
||||
CefV8StackTraceCToCpp::Wrap(stackTrace));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK render_process_handler_on_focused_node_changed(
|
||||
struct _cef_render_process_handler_t* self, cef_browser_t* browser,
|
||||
cef_frame_t* frame, cef_domnode_t* node) {
|
||||
|
@ -374,12 +290,6 @@ CefRenderProcessHandlerCppToC::CefRenderProcessHandlerCppToC(
|
|||
render_process_handler_on_context_released;
|
||||
struct_.struct_.on_uncaught_exception =
|
||||
render_process_handler_on_uncaught_exception;
|
||||
struct_.struct_.on_worker_context_created =
|
||||
render_process_handler_on_worker_context_created;
|
||||
struct_.struct_.on_worker_context_released =
|
||||
render_process_handler_on_worker_context_released;
|
||||
struct_.struct_.on_worker_uncaught_exception =
|
||||
render_process_handler_on_worker_uncaught_exception;
|
||||
struct_.struct_.on_focused_node_changed =
|
||||
render_process_handler_on_focused_node_changed;
|
||||
struct_.struct_.on_process_message_received =
|
||||
|
|
|
@ -214,87 +214,6 @@ void CefRenderProcessHandlerCToCpp::OnUncaughtException(
|
|||
CefV8StackTraceCppToC::Wrap(stackTrace));
|
||||
}
|
||||
|
||||
void CefRenderProcessHandlerCToCpp::OnWorkerContextCreated(int worker_id,
|
||||
const CefString& url, CefRefPtr<CefV8Context> context) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_worker_context_created))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(!url.empty());
|
||||
if (url.empty())
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context.get());
|
||||
if (!context.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_worker_context_created(struct_,
|
||||
worker_id,
|
||||
url.GetStruct(),
|
||||
CefV8ContextCppToC::Wrap(context));
|
||||
}
|
||||
|
||||
void CefRenderProcessHandlerCToCpp::OnWorkerContextReleased(int worker_id,
|
||||
const CefString& url, CefRefPtr<CefV8Context> context) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_worker_context_released))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(!url.empty());
|
||||
if (url.empty())
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context.get());
|
||||
if (!context.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_worker_context_released(struct_,
|
||||
worker_id,
|
||||
url.GetStruct(),
|
||||
CefV8ContextCppToC::Wrap(context));
|
||||
}
|
||||
|
||||
void CefRenderProcessHandlerCToCpp::OnWorkerUncaughtException(int worker_id,
|
||||
const CefString& url, CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_worker_uncaught_exception))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: url; type: string_byref_const
|
||||
DCHECK(!url.empty());
|
||||
if (url.empty())
|
||||
return;
|
||||
// Verify param: context; type: refptr_diff
|
||||
DCHECK(context.get());
|
||||
if (!context.get())
|
||||
return;
|
||||
// Verify param: exception; type: refptr_diff
|
||||
DCHECK(exception.get());
|
||||
if (!exception.get())
|
||||
return;
|
||||
// Verify param: stackTrace; type: refptr_diff
|
||||
DCHECK(stackTrace.get());
|
||||
if (!stackTrace.get())
|
||||
return;
|
||||
|
||||
// Execute
|
||||
struct_->on_worker_uncaught_exception(struct_,
|
||||
worker_id,
|
||||
url.GetStruct(),
|
||||
CefV8ContextCppToC::Wrap(context),
|
||||
CefV8ExceptionCppToC::Wrap(exception),
|
||||
CefV8StackTraceCppToC::Wrap(stackTrace));
|
||||
}
|
||||
|
||||
void CefRenderProcessHandlerCToCpp::OnFocusedNodeChanged(
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) {
|
||||
|
|
|
@ -50,13 +50,6 @@ class CefRenderProcessHandlerCToCpp
|
|||
CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
|
||||
virtual void OnWorkerContextCreated(int worker_id, const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
virtual void OnWorkerContextReleased(int worker_id, const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
virtual void OnWorkerUncaughtException(int worker_id, const CefString& url,
|
||||
CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame, CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
|
|
|
@ -26,11 +26,6 @@ patches = [
|
|||
'name': 'message_loop_443',
|
||||
'path': '../base/',
|
||||
},
|
||||
{
|
||||
# http://code.google.com/p/chromiumembedded/issues/detail?id=451
|
||||
'name': 'webkit_451',
|
||||
'path': '../third_party/WebKit/Source/',
|
||||
},
|
||||
{
|
||||
# http://code.google.com/p/chromiumembedded/issues/detail?id=899
|
||||
'name': 'webkit_features',
|
||||
|
|
|
@ -335,35 +335,6 @@ void ClientApp::OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
|||
}
|
||||
}
|
||||
|
||||
void ClientApp::OnWorkerContextCreated(int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||
for (; it != render_delegates_.end(); ++it)
|
||||
(*it)->OnWorkerContextCreated(this, worker_id, url, context);
|
||||
}
|
||||
|
||||
void ClientApp::OnWorkerContextReleased(int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {
|
||||
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||
for (; it != render_delegates_.end(); ++it)
|
||||
(*it)->OnWorkerContextReleased(this, worker_id, url, context);
|
||||
}
|
||||
|
||||
void ClientApp::OnWorkerUncaughtException(
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {
|
||||
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||
for (; it != render_delegates_.end(); ++it) {
|
||||
(*it)->OnWorkerUncaughtException(this, worker_id, url, context, exception,
|
||||
stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) {
|
||||
|
|
|
@ -77,24 +77,6 @@ class ClientApp : public CefApp,
|
|||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
virtual void OnWorkerContextCreated(CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnWorkerContextReleased(CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnWorkerUncaughtException(
|
||||
CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
|
@ -186,21 +168,6 @@ class ClientApp : public CefApp,
|
|||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace)
|
||||
OVERRIDE;
|
||||
virtual void OnWorkerContextCreated(
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
virtual void OnWorkerContextReleased(
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
virtual void OnWorkerUncaughtException(
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace)
|
||||
OVERRIDE;
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
|
|
|
@ -74,9 +74,6 @@ enum V8TestMode {
|
|||
V8TEST_ON_UNCAUGHT_EXCEPTION,
|
||||
V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS,
|
||||
V8TEST_EXTENSION,
|
||||
V8TEST_WORKER_BINDING,
|
||||
V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION,
|
||||
V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS,
|
||||
};
|
||||
|
||||
// Set to the current test being run in the browser process. Will always be
|
||||
|
@ -220,16 +217,11 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
|||
RunStackTraceTest();
|
||||
break;
|
||||
case V8TEST_ON_UNCAUGHT_EXCEPTION:
|
||||
case V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION:
|
||||
RunOnUncaughtExceptionTest();
|
||||
break;
|
||||
case V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS:
|
||||
case V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS:
|
||||
RunOnUncaughtExceptionDevToolsTest();
|
||||
break;
|
||||
case V8TEST_WORKER_BINDING:
|
||||
// The test is triggered in OnWorkerContextCreated().
|
||||
break;
|
||||
default:
|
||||
// Was a startup test.
|
||||
EXPECT_TRUE(startup_test_success_);
|
||||
|
@ -1652,8 +1644,7 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
|||
if (test_mode_ == V8TEST_NONE)
|
||||
return;
|
||||
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (browser_.get() == NULL) {
|
||||
app_ = app;
|
||||
browser_ = browser;
|
||||
|
@ -1769,204 +1760,12 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void OnWorkerContextCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
if (test_mode_ == V8TEST_NONE)
|
||||
return;
|
||||
|
||||
EXPECT_STREQ(kV8WorkerTestUrl, url.ToString().c_str());
|
||||
|
||||
EXPECT_TRUE(context.get());
|
||||
EXPECT_TRUE(context->IsValid());
|
||||
test_context_worker_ = context;
|
||||
|
||||
CefRefPtr<CefTaskRunner> task_runner = context->GetTaskRunner();
|
||||
EXPECT_TRUE(task_runner.get());
|
||||
EXPECT_TRUE(task_runner->BelongsToCurrentThread());
|
||||
test_task_runner_worker_ = task_runner;
|
||||
|
||||
EXPECT_FALSE(context->GetBrowser().get());
|
||||
EXPECT_FALSE(context->GetFrame().get());
|
||||
|
||||
if (test_mode_ == V8TEST_WORKER_BINDING) {
|
||||
static const char test_func[] = "run_async";
|
||||
|
||||
class Handler : public CefV8Handler {
|
||||
public:
|
||||
Handler() {}
|
||||
virtual bool Execute(const CefString& name,
|
||||
CefRefPtr<CefV8Value> object,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) OVERRIDE {
|
||||
EXPECT_STREQ(test_func, name.ToString().c_str());
|
||||
EXPECT_EQ((size_t)1, arguments.size());
|
||||
|
||||
callback_ = arguments[0];
|
||||
EXPECT_TRUE(callback_->IsFunction());
|
||||
|
||||
EXPECT_TRUE(context_->IsValid());
|
||||
|
||||
CefRefPtr<CefV8Context> current_context =
|
||||
CefV8Context::GetCurrentContext();
|
||||
EXPECT_TRUE(current_context->IsSame(context_));
|
||||
|
||||
CefRefPtr<CefTaskRunner> task_runner =
|
||||
current_context->GetTaskRunner();
|
||||
EXPECT_TRUE(task_runner.get());
|
||||
EXPECT_TRUE(task_runner->BelongsToCurrentThread());
|
||||
EXPECT_TRUE(task_runner->IsSame(task_runner_));
|
||||
|
||||
// Execute the callback asynchronously.
|
||||
// Can't use templates with nested classes on Linux.
|
||||
class Task : public CefTask {
|
||||
public:
|
||||
explicit Task(Handler* handler)
|
||||
: handler_(handler) {
|
||||
handler_->AddRef();
|
||||
}
|
||||
~Task() {
|
||||
handler_->Release();
|
||||
}
|
||||
virtual void Execute() OVERRIDE {
|
||||
handler_->ExecCallback();
|
||||
}
|
||||
private:
|
||||
Handler* handler_;
|
||||
IMPLEMENT_REFCOUNTING(Task);
|
||||
};
|
||||
task_runner->PostTask(new Task(this));
|
||||
|
||||
retval = CefV8Value::CreateBool(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ExecCallback() {
|
||||
EXPECT_TRUE(callback_->IsValid());
|
||||
EXPECT_TRUE(context_->IsValid());
|
||||
|
||||
CefRefPtr<CefTaskRunner> task_runner = context_->GetTaskRunner();
|
||||
EXPECT_TRUE(task_runner.get());
|
||||
EXPECT_TRUE(task_runner->BelongsToCurrentThread());
|
||||
EXPECT_TRUE(task_runner->IsSame(task_runner_));
|
||||
|
||||
CefRefPtr<CefV8Value> retval =
|
||||
callback_->ExecuteFunctionWithContext(context_, NULL,
|
||||
CefV8ValueList());
|
||||
EXPECT_TRUE(retval.get());
|
||||
EXPECT_TRUE(retval->IsValid());
|
||||
EXPECT_TRUE(retval->IsBool());
|
||||
EXPECT_EQ(true, retval->GetBoolValue());
|
||||
|
||||
callback_ = NULL;
|
||||
context_ = NULL;
|
||||
task_runner_ = NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> callback_;
|
||||
CefRefPtr<CefV8Context> context_;
|
||||
CefRefPtr<CefTaskRunner> task_runner_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(Handler);
|
||||
};
|
||||
|
||||
Handler* handler = new Handler();
|
||||
CefRefPtr<CefV8Handler> handlerPtr(handler);
|
||||
|
||||
handler->context_ = context;
|
||||
handler->task_runner_ = task_runner;
|
||||
|
||||
CefRefPtr<CefV8Value> global = context->GetGlobal();
|
||||
EXPECT_TRUE(global.get());
|
||||
|
||||
global->SetValue(test_func,
|
||||
CefV8Value::CreateFunction(test_func, handlerPtr),
|
||||
V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnWorkerContextReleased(
|
||||
CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
if (test_mode_ == V8TEST_NONE)
|
||||
return;
|
||||
|
||||
EXPECT_STREQ(kV8WorkerTestUrl, url.ToString().c_str());
|
||||
|
||||
EXPECT_TRUE(context.get());
|
||||
EXPECT_TRUE(context->IsValid());
|
||||
|
||||
CefRefPtr<CefTaskRunner> task_runner = context->GetTaskRunner();
|
||||
EXPECT_TRUE(task_runner.get());
|
||||
EXPECT_TRUE(task_runner->BelongsToCurrentThread());
|
||||
EXPECT_TRUE(task_runner->IsSame(test_task_runner_worker_));
|
||||
|
||||
EXPECT_TRUE(context->IsSame(test_context_worker_));
|
||||
|
||||
test_context_worker_ = NULL;
|
||||
test_task_runner_worker_ = NULL;
|
||||
|
||||
if (test_mode_ == V8TEST_WORKER_BINDING) {
|
||||
// Destroy the test on the renderer thread.
|
||||
CefPostTask(TID_RENDERER,
|
||||
NewCefRunnableMethod(this, &V8RendererTest::DestroyTest));
|
||||
}
|
||||
}
|
||||
|
||||
void OnWorkerUncaughtException(
|
||||
CefRefPtr<ClientApp> app,
|
||||
int worker_id,
|
||||
const CefString& url,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE {
|
||||
if (test_mode_ == V8TEST_NONE)
|
||||
return;
|
||||
|
||||
EXPECT_TRUE(context.get());
|
||||
EXPECT_TRUE(context->IsValid());
|
||||
|
||||
CefRefPtr<CefTaskRunner> task_runner = context->GetTaskRunner();
|
||||
EXPECT_TRUE(task_runner.get());
|
||||
EXPECT_TRUE(task_runner->BelongsToCurrentThread());
|
||||
EXPECT_TRUE(task_runner->IsSame(test_task_runner_worker_));
|
||||
|
||||
EXPECT_TRUE(context->IsSame(test_context_worker_));
|
||||
|
||||
if (test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
EXPECT_STREQ("Uncaught ReferenceError: asd is not defined",
|
||||
exception->GetMessage().ToString().c_str());
|
||||
std::ostringstream stackFormatted;
|
||||
for (int i = 0; i < stackTrace->GetFrameCount(); ++i) {
|
||||
stackFormatted << "at "
|
||||
<< stackTrace->GetFrame(i)->GetFunctionName().ToString()
|
||||
<< "() in " << stackTrace->GetFrame(i)->GetScriptName().ToString()
|
||||
<< " on line " << stackTrace->GetFrame(i)->GetLineNumber() << "\n";
|
||||
}
|
||||
const char* stackFormattedShouldBe =
|
||||
"at test2() in http://tests/V8Test.Worker.js on line 2\n"
|
||||
"at test() in http://tests/V8Test.Worker.js on line 1\n";
|
||||
EXPECT_STREQ(stackFormattedShouldBe, stackFormatted.str().c_str());
|
||||
|
||||
// Destroy the test on the renderer thread.
|
||||
CefPostTask(TID_RENDERER,
|
||||
NewCefRunnableMethod(this, &V8RendererTest::DestroyTest));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnBrowserDestroyed(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser) OVERRIDE {
|
||||
if (test_mode_ == V8TEST_NONE)
|
||||
return;
|
||||
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (browser->IsPopup()) {
|
||||
// After window destruction there is still a call to
|
||||
// ScriptController::setCaptureCallStackForUncaughtExceptions(0),
|
||||
|
@ -1985,8 +1784,7 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
|||
if (test_mode_ == V8TEST_NONE)
|
||||
return false;
|
||||
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
EXPECT_TRUE(browser.get());
|
||||
EXPECT_EQ(PID_BROWSER, source_process);
|
||||
EXPECT_TRUE(message.get());
|
||||
|
@ -2132,9 +1930,6 @@ class V8RendererTest : public ClientApp::RenderDelegate {
|
|||
CefRefPtr<CefV8Context> test_context_;
|
||||
CefRefPtr<CefV8Value> test_object_;
|
||||
|
||||
CefRefPtr<CefV8Context> test_context_worker_;
|
||||
CefRefPtr<CefTaskRunner> test_task_runner_worker_;
|
||||
|
||||
// Used by startup tests to indicate success.
|
||||
TrackCallback startup_test_success_;
|
||||
|
||||
|
@ -2171,28 +1966,6 @@ class V8TestHandler : public TestHandler {
|
|||
"</body></html>\n",
|
||||
"text/html");
|
||||
CreateBrowser(kV8OnUncaughtExceptionTestUrl);
|
||||
} else if (test_mode_ == V8TEST_WORKER_BINDING) {
|
||||
AddResource(kV8WorkerParentTestUrl, "<html><body>"
|
||||
"<script>var worker = new Worker('V8Test.Worker.js');</script>"
|
||||
"</body></html>", "text/html");
|
||||
AddResource(kV8WorkerTestUrl,
|
||||
"function cb() { self.close(); return true; }\n"
|
||||
"self.run_async(cb);",
|
||||
"application/javascript");
|
||||
CreateBrowser(kV8WorkerParentTestUrl);
|
||||
} else if (test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
AddResource(kV8WorkerParentTestUrl, "<html><body>"
|
||||
"<script>var worker = new Worker('V8Test.Worker.js');\n"
|
||||
"function test() { worker.postMessage('test'); }\n"
|
||||
"</script>"
|
||||
"</body></html>", "text/html");
|
||||
AddResource(kV8WorkerTestUrl,
|
||||
"function test(){ test2(); }\n"
|
||||
"function test2(){ asd(); }\n"
|
||||
"self.onmessage = function(event) { self.setTimeout(test, 0); }",
|
||||
"application/javascript");
|
||||
CreateBrowser(kV8WorkerParentTestUrl);
|
||||
} else {
|
||||
EXPECT_TRUE(test_url_ != NULL);
|
||||
AddResource(test_url_, "<html><body>"
|
||||
|
@ -2204,8 +1977,7 @@ class V8TestHandler : public TestHandler {
|
|||
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode) OVERRIDE {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS ||
|
||||
test_mode_ == V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (test_mode_ == V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS) {
|
||||
if (browser->IsPopup()) {
|
||||
EXPECT_STREQ(
|
||||
GetBrowser()->GetHost()->GetDevToolsURL(true).ToString().c_str(),
|
||||
|
@ -2329,7 +2101,3 @@ V8_TEST(StackTrace, V8TEST_STACK_TRACE);
|
|||
V8_TEST(OnUncaughtException, V8TEST_ON_UNCAUGHT_EXCEPTION);
|
||||
V8_TEST(OnUncaughtExceptionDevTools, V8TEST_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS);
|
||||
V8_TEST(Extension, V8TEST_EXTENSION);
|
||||
V8_TEST(WorkerBinding, V8TEST_WORKER_BINDING);
|
||||
V8_TEST(WorkerOnUncaughtException, V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION);
|
||||
V8_TEST(WorkerOnUncaughtExceptionDevTools,
|
||||
V8TEST_WORKER_ON_UNCAUGHT_EXCEPTION_DEV_TOOLS);
|
||||
|
|
Loading…
Reference in New Issue