Diff
Modified: trunk/Source/WebCore/ChangeLog (128138 => 128139)
--- trunk/Source/WebCore/ChangeLog 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/ChangeLog 2012-09-11 01:25:03 UTC (rev 128139)
@@ -1,5 +1,53 @@
2012-09-10 Adam Barth <[email protected]>
+ [V8] Code assumes that getScriptExecutionContext can return 0
+ https://bugs.webkit.org/show_bug.cgi?id=96340
+
+ Reviewed by Eric Seidel.
+
+ This function can never return 0 (as long as V8 is on the stack).
+ There's no reason to try to handle a 0 return as an error.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateCallWith):
+ (GenerateConstructorCallback):
+ * bindings/scripts/test/V8/V8TestInterface.cpp:
+ (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback):
+ (WebCore::V8TestInterface::constructorCallback):
+ * bindings/scripts/test/V8/V8TestObj.cpp:
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrSetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrSetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrSetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrSetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextCallback):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateCallback):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesCallback):
+ * bindings/v8/custom/V8BlobCustom.cpp:
+ (WebCore::V8Blob::constructorCallback):
+ * bindings/v8/custom/V8CustomXPathNSResolver.cpp:
+ (WebCore::V8CustomXPathNSResolver::lookupNamespaceURI):
+ * bindings/v8/custom/V8MessageChannelConstructor.cpp:
+ (WebCore::V8MessageChannel::constructorCallback):
+ * bindings/v8/custom/V8MutationObserverCustom.cpp:
+ (WebCore::V8MutationObserver::constructorCallback):
+ * bindings/v8/custom/V8SQLTransactionCustom.cpp:
+ (WebCore::V8SQLTransaction::executeSqlCallback):
+ * bindings/v8/custom/V8WebSocketCustom.cpp:
+ (WebCore::V8WebSocket::constructorCallback):
+ * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+ (WebCore::V8XMLHttpRequest::constructorCallback):
+ * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
+ (WebCore::V8XMLHttpRequest::openCallback):
+
+2012-09-10 Adam Barth <[email protected]>
+
[V8] We don't us the global handle map for anything useful---let's remove it
https://bugs.webkit.org/show_bug.cgi?id=96343
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (128138 => 128139)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-09-11 01:25:03 UTC (rev 128139)
@@ -1598,8 +1598,6 @@
}
if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) {
push(@$outputArray, $indent . "ScriptExecutionContext* scriptContext = getScriptExecutionContext();\n");
- push(@$outputArray, $indent . "if (!scriptContext)\n");
- push(@$outputArray, $indent . " return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");
push(@callWithArgs, "scriptContext");
}
if ($function and $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments")) {
@@ -1848,8 +1846,6 @@
push(@implContent, <<END);
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "${implClassName} constructor's associated context is not available", args.GetIsolate());
END
}
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -163,8 +163,6 @@
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined))) : 0);
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
RefPtr<TestObj> result = TestSupplemental::supplementalMethod2(scriptContext, imp, strArg, objArg, ec);
if (UNLIKELY(ec))
goto fail;
@@ -259,8 +257,6 @@
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "TestInterface constructor's associated context is not available", args.GetIsolate());
RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, ec);
v8::Handle<v8::Object> wrapper = args.Holder();
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -546,8 +546,6 @@
INC_STATS("DOM.TestObj.withScriptExecutionContextAttribute._get");
TestObj* imp = V8TestObj::toNative(info.Holder());
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
return toV8(imp->withScriptExecutionContextAttribute(scriptContext), info.Holder(), info.GetIsolate());
}
@@ -557,8 +555,6 @@
TestObj* imp = V8TestObj::toNative(info.Holder());
TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return;
imp->setWithScriptExecutionContextAttribute(scriptContext, WTF::getPtr(v));
return;
}
@@ -602,8 +598,6 @@
TestObj* imp = V8TestObj::toNative(info.Holder());
ExceptionCode ec = 0;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
RefPtr<TestObj> v = imp->withScriptExecutionContextAttributeRaises(scriptContext, ec);
if (UNLIKELY(ec))
return setDOMException(ec, info.GetIsolate());
@@ -617,8 +611,6 @@
TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
ExceptionCode ec = 0;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return;
imp->setWithScriptExecutionContextAttributeRaises(scriptContext, WTF::getPtr(v), ec);
if (UNLIKELY(ec))
setDOMException(ec, info.GetIsolate());
@@ -633,8 +625,6 @@
if (!state)
return v8Undefined();
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext), info.Holder(), info.GetIsolate());
}
@@ -647,8 +637,6 @@
if (!state)
return;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return;
imp->setWithScriptExecutionContextAndScriptStateAttribute(state, scriptContext, WTF::getPtr(v));
if (state.hadException())
throwError(state.exception(), info.GetIsolate());
@@ -664,8 +652,6 @@
if (!state)
return v8Undefined();
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
RefPtr<TestObj> v = imp->withScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, ec);
if (UNLIKELY(ec))
return setDOMException(ec, info.GetIsolate());
@@ -684,8 +670,6 @@
if (!state)
return;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return;
imp->setWithScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, WTF::getPtr(v), ec);
if (UNLIKELY(ec))
setDOMException(ec, info.GetIsolate());
@@ -702,8 +686,6 @@
if (!state)
return v8Undefined();
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext), info.Holder(), info.GetIsolate());
}
@@ -716,8 +698,6 @@
if (!state)
return;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return;
imp->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext, WTF::getPtr(v));
if (state.hadException())
throwError(state.exception(), info.GetIsolate());
@@ -1311,8 +1291,6 @@
INC_STATS("DOM.TestObj.withScriptExecutionContext");
TestObj* imp = V8TestObj::toNative(args.Holder());
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
imp->withScriptExecutionContext(scriptContext);
return v8Undefined();
}
@@ -1323,8 +1301,6 @@
TestObj* imp = V8TestObj::toNative(args.Holder());
EmptyScriptState state;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
imp->withScriptExecutionContextAndScriptState(&state, scriptContext);
if (state.hadException())
return throwError(state.exception(), args.GetIsolate());
@@ -1339,8 +1315,6 @@
{
EmptyScriptState state;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
RefPtr<TestObj> result = imp->withScriptExecutionContextAndScriptStateObjException(&state, scriptContext, ec);
if (UNLIKELY(ec))
goto fail;
@@ -1358,8 +1332,6 @@
TestObj* imp = V8TestObj::toNative(args.Holder());
EmptyScriptState state;
ScriptExecutionContext* scriptContext = getScriptExecutionContext();
- if (!scriptContext)
- return v8Undefined();
RefPtr<TestObj> result = imp->withScriptExecutionContextAndScriptStateWithSpaces(&state, scriptContext);
if (state.hadException())
return throwError(state.exception(), args.GetIsolate());
Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -64,10 +64,7 @@
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
- // Get the script execution context.
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "Blob constructor associated document is unavailable", args.GetIsolate());
if (!args.Length()) {
RefPtr<Blob> blob = Blob::create();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -30,6 +30,8 @@
#include "config.h"
#include "V8CustomXPathNSResolver.h"
+#include "Console.h"
+#include "DOMWindow.h"
#include "ScriptCallStack.h"
#include "ScriptController.h"
#include "ScriptExecutionContext.h"
@@ -66,14 +68,13 @@
}
if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
- if (ScriptExecutionContext* context = getScriptExecutionContext())
- context->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
+ activeDOMWindow(BindingState::instance())->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method.");
return String();
}
// Catch exceptions from calling the namespace resolver.
- v8::TryCatch try_catch;
- try_catch.SetVerbose(true); // Print exceptions to console.
+ v8::TryCatch tryCatch;
+ tryCatch.SetVerbose(true); // Print exceptions to console.
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { v8String(prefix) };
@@ -82,7 +83,7 @@
v8::Handle<v8::Value> retval = ScriptController::callFunctionWithInstrumentation(0, function, m_resolver, argc, argv);
// Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR.
- if (try_catch.HasCaught())
+ if (tryCatch.HasCaught())
return String();
return toWebCoreStringWithNullCheck(retval);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -47,36 +47,28 @@
v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments& args)
{
INC_STATS("DOM.MessageChannel.Constructor");
- // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
- // Consider refactoring to reduce duplication.
+
if (!args.IsConstructCall())
return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
- // Get the ScriptExecutionContext (WorkerContext or Document)
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return v8::Undefined();
- // Note: it's OK to let this RefPtr go out of scope because we also call
- // SetDOMWrapper(), which effectively holds a reference to obj.
RefPtr<MessageChannel> obj = MessageChannel::create(context);
- v8::Local<v8::Object> messageChannel = args.Holder();
+ v8::Local<v8::Object> wrapper = args.Holder();
// Create references from the MessageChannel wrapper to the two
// MessagePort wrappers to make sure that the MessagePort wrappers
// stay alive as long as the MessageChannel wrapper is around.
- V8DOMWrapper::setNamedHiddenReference(messageChannel, "port1", toV8(obj->port1(), args.Holder(), args.GetIsolate()));
- V8DOMWrapper::setNamedHiddenReference(messageChannel, "port2", toV8(obj->port2(), args.Holder(), args.GetIsolate()));
+ V8DOMWrapper::setNamedHiddenReference(wrapper, "port1", toV8(obj->port1(), args.Holder(), args.GetIsolate()));
+ V8DOMWrapper::setNamedHiddenReference(wrapper, "port2", toV8(obj->port2(), args.Holder(), args.GetIsolate()));
- // Setup the standard wrapper object internal fields.
- V8DOMWrapper::setDOMWrapper(messageChannel, &info, obj.get());
- V8DOMWrapper::setJSWrapperForDOMObject(obj.release(), messageChannel);
- return messageChannel;
+ V8DOMWrapper::setDOMWrapper(wrapper, &info, obj.get());
+ V8DOMWrapper::setJSWrapperForDOMObject(obj.release(), wrapper);
+ return wrapper;
}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -61,8 +61,6 @@
return setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate());
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "MutationObserver constructor's associated frame unavailable", args.GetIsolate());
RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context);
RefPtr<MutationObserver> observer = MutationObserver::create(callback.release());
Modified: trunk/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -89,8 +89,6 @@
SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder());
ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext();
- if (!scriptExecutionContext)
- return v8::Undefined();
RefPtr<SQLStatementCallback> callback;
if (args.Length() > 2 && !isUndefinedOrNull(args[2])) {
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -71,11 +71,7 @@
if (urlstring.IsEmpty())
return throwError(SyntaxError, "Empty URL", args.GetIsolate());
- // Get the script execution context.
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "WebSocket constructor's associated frame is not available", args.GetIsolate());
-
const KURL& url = ""
RefPtr<WebSocket> webSocket = WebSocket::create(context);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -52,16 +52,14 @@
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
- // Expect no parameters.
- // Allocate a XMLHttpRequest object as its internal field.
ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return throwError(ReferenceError, "XMLHttpRequest constructor's associated context is not available", args.GetIsolate());
RefPtr<SecurityOrigin> securityOrigin;
if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered())
securityOrigin = isolatedContext->securityOrigin();
+
RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin);
+
v8::Handle<v8::Object> wrapper = args.Holder();
V8DOMWrapper::setDOMWrapper(wrapper, &info, xmlHttpRequest.get());
V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.release(), wrapper);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp (128138 => 128139)
--- trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp 2012-09-11 01:22:17 UTC (rev 128138)
+++ trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp 2012-09-11 01:25:03 UTC (rev 128139)
@@ -117,10 +117,8 @@
String method = toWebCoreString(args[0]);
String urlstring = toWebCoreString(args[1]);
- ScriptExecutionContext* context = getScriptExecutionContext();
- if (!context)
- return v8::Undefined();
+ ScriptExecutionContext* context = getScriptExecutionContext();
KURL url = ""
ExceptionCode ec = 0;