Commit 97f7831a authored by haraken@chromium.org's avatar haraken@chromium.org

Remove V8TryCatchRethrowScope from private script bindings

When a private script throws an exception, what the private script binding does is:

- if the exception is the one supported in private scripts,
the private script binding clones the exception in the user's script and throws it.

- if the exception is the one not (yet) supported in private scripts,
the private script binding dies.

Since these operations are done explicitly, we should use ReThrow()
instead of relying on V8TryCatchRethrowScope. (V8TryCatchRethrowScope is not
a proper mechanism for doing this because V8TryCatchRethrowScope is intended
to be used to rethrow an exception the way it is without doing any conversion.)

BUG=341031

Review URL: https://codereview.chromium.org/461593002

git-svn-id: svn://svn.chromium.org/blink/trunk@179955 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6bc65d9c
...@@ -359,13 +359,13 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeGetter(LocalFrame* ...@@ -359,13 +359,13 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeGetter(LocalFrame*
ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(scriptState, "{{cpp_class}}", "{{attribute.name}}", holder); v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(scriptState, "{{cpp_class}}", "{{attribute.name}}", holder);
if (block.HasCaught()) { if (block.HasCaught()) {
if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) { if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) {
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
{{attribute.private_script_v8_value_to_local_cpp_value}}; {{attribute.private_script_v8_value_to_local_cpp_value}};
...@@ -395,13 +395,13 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame* ...@@ -395,13 +395,13 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
PrivateScriptRunner::runDOMAttributeSetter(scriptState, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_script_cpp_value_to_v8_value}}); PrivateScriptRunner::runDOMAttributeSetter(scriptState, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_script_cpp_value_to_v8_value}});
if (block.HasCaught()) { if (block.HasCaught()) {
if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) { if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) {
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
return true; return true;
......
...@@ -561,7 +561,6 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ...@@ -561,7 +561,6 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar
{% endif %} {% endif %}
ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
{% if method.idl_type == 'void' %} {% if method.idl_type == 'void' %}
PrivateScriptRunner::runDOMMethod(scriptState, "{{cpp_class}}", "{{method.name}}", holder, {{method.arguments | length}}, argv); PrivateScriptRunner::runDOMMethod(scriptState, "{{cpp_class}}", "{{method.name}}", holder, {{method.arguments | length}}, argv);
if (block.HasCaught()) { if (block.HasCaught()) {
...@@ -569,6 +568,7 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ...@@ -569,6 +568,7 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
{% else %} {% else %}
...@@ -578,6 +578,7 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ...@@ -578,6 +578,7 @@ bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
{{method.private_script_v8_value_to_local_cpp_value}}; {{method.private_script_v8_value_to_local_cpp_value}};
......
...@@ -1875,13 +1875,13 @@ bool V8TestInterface::PrivateScript::shortMethodWithShortArgumentImplementedInPr ...@@ -1875,13 +1875,13 @@ bool V8TestInterface::PrivateScript::shortMethodWithShortArgumentImplementedInPr
v8::Handle<v8::Value> argv[] = { valueHandle }; v8::Handle<v8::Value> argv[] = { valueHandle };
ExceptionState exceptionState(ExceptionState::ExecutionContext, "shortMethodWithShortArgumentImplementedInPrivateScript", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::ExecutionContext, "shortMethodWithShortArgumentImplementedInPrivateScript", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptState, "TestInterfaceImplementation", "shortMethodWithShortArgumentImplementedInPrivateScript", holder, 1, argv); v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptState, "TestInterfaceImplementation", "shortMethodWithShortArgumentImplementedInPrivateScript", holder, 1, argv);
if (block.HasCaught()) { if (block.HasCaught()) {
if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) { if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) {
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
TONATIVE_DEFAULT_EXCEPTIONSTATE(int, cppValue, toInt16(v8Value, exceptionState), exceptionState, false); TONATIVE_DEFAULT_EXCEPTIONSTATE(int, cppValue, toInt16(v8Value, exceptionState), exceptionState, false);
...@@ -1908,13 +1908,13 @@ bool V8TestInterface::PrivateScript::stringAttributeAttributeGetter(LocalFrame* ...@@ -1908,13 +1908,13 @@ bool V8TestInterface::PrivateScript::stringAttributeAttributeGetter(LocalFrame*
ExceptionState exceptionState(ExceptionState::GetterContext, "stringAttribute", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::GetterContext, "stringAttribute", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(scriptState, "TestInterfaceImplementation", "stringAttribute", holder); v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(scriptState, "TestInterfaceImplementation", "stringAttribute", holder);
if (block.HasCaught()) { if (block.HasCaught()) {
if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) { if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) {
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
TOSTRING_DEFAULT(V8StringResource<>, cppValue, v8Value, false); TOSTRING_DEFAULT(V8StringResource<>, cppValue, v8Value, false);
...@@ -1941,13 +1941,13 @@ bool V8TestInterface::PrivateScript::stringAttributeAttributeSetter(LocalFrame* ...@@ -1941,13 +1941,13 @@ bool V8TestInterface::PrivateScript::stringAttributeAttributeSetter(LocalFrame*
ExceptionState exceptionState(ExceptionState::SetterContext, "stringAttribute", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate()); ExceptionState exceptionState(ExceptionState::SetterContext, "stringAttribute", "TestInterfaceImplementation", scriptState->context()->Global(), scriptState->isolate());
v8::TryCatch block; v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
PrivateScriptRunner::runDOMAttributeSetter(scriptState, "TestInterfaceImplementation", "stringAttribute", holder, v8String(scriptState->isolate(), cppValue)); PrivateScriptRunner::runDOMAttributeSetter(scriptState, "TestInterfaceImplementation", "stringAttribute", holder, v8String(scriptState->isolate(), cppValue));
if (block.HasCaught()) { if (block.HasCaught()) {
if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) { if (!PrivateScriptRunner::throwDOMExceptionInPrivateScriptIfNeeded(scriptState->isolate(), exceptionState, block.Exception())) {
// FIXME: We should support more exceptions. // FIXME: We should support more exceptions.
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
block.ReThrow();
return false; return false;
} }
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment