Changeset 128139 in webkit
- Timestamp:
- Sep 10, 2012 6:25:03 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128138 r128139 1 2012-09-10 Adam Barth <abarth@chromium.org> 2 3 [V8] Code assumes that getScriptExecutionContext can return 0 4 https://bugs.webkit.org/show_bug.cgi?id=96340 5 6 Reviewed by Eric Seidel. 7 8 This function can never return 0 (as long as V8 is on the stack). 9 There's no reason to try to handle a 0 return as an error. 10 11 * bindings/scripts/CodeGeneratorV8.pm: 12 (GenerateCallWith): 13 (GenerateConstructorCallback): 14 * bindings/scripts/test/V8/V8TestInterface.cpp: 15 (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback): 16 (WebCore::V8TestInterface::constructorCallback): 17 * bindings/scripts/test/V8/V8TestObj.cpp: 18 (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrGetter): 19 (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrSetter): 20 (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter): 21 (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrSetter): 22 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrGetter): 23 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrSetter): 24 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter): 25 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter): 26 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter): 27 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrSetter): 28 (WebCore::TestObjV8Internal::withScriptExecutionContextCallback): 29 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateCallback): 30 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback): 31 (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesCallback): 32 * bindings/v8/custom/V8BlobCustom.cpp: 33 (WebCore::V8Blob::constructorCallback): 34 * bindings/v8/custom/V8CustomXPathNSResolver.cpp: 35 (WebCore::V8CustomXPathNSResolver::lookupNamespaceURI): 36 * bindings/v8/custom/V8MessageChannelConstructor.cpp: 37 (WebCore::V8MessageChannel::constructorCallback): 38 * bindings/v8/custom/V8MutationObserverCustom.cpp: 39 (WebCore::V8MutationObserver::constructorCallback): 40 * bindings/v8/custom/V8SQLTransactionCustom.cpp: 41 (WebCore::V8SQLTransaction::executeSqlCallback): 42 * bindings/v8/custom/V8WebSocketCustom.cpp: 43 (WebCore::V8WebSocket::constructorCallback): 44 * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp: 45 (WebCore::V8XMLHttpRequest::constructorCallback): 46 * bindings/v8/custom/V8XMLHttpRequestCustom.cpp: 47 (WebCore::V8XMLHttpRequest::openCallback): 48 1 49 2012-09-10 Adam Barth <abarth@chromium.org> 2 50 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r128102 r128139 1599 1599 if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) { 1600 1600 push(@$outputArray, $indent . "ScriptExecutionContext* scriptContext = getScriptExecutionContext();\n"); 1601 push(@$outputArray, $indent . "if (!scriptContext)\n");1602 push(@$outputArray, $indent . " return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");1603 1601 push(@callWithArgs, "scriptContext"); 1604 1602 } … … 1849 1847 1850 1848 ScriptExecutionContext* context = getScriptExecutionContext(); 1851 if (!context)1852 return throwError(ReferenceError, "${implClassName} constructor's associated context is not available", args.GetIsolate());1853 1849 END 1854 1850 } -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
r127972 r128139 164 164 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); 165 165 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 166 if (!scriptContext)167 return v8Undefined();168 166 RefPtr<TestObj> result = TestSupplemental::supplementalMethod2(scriptContext, imp, strArg, objArg, ec); 169 167 if (UNLIKELY(ec)) … … 260 258 261 259 ScriptExecutionContext* context = getScriptExecutionContext(); 262 if (!context)263 return throwError(ReferenceError, "TestInterface constructor's associated context is not available", args.GetIsolate());264 260 265 261 RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, ec); -
trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r127972 r128139 547 547 TestObj* imp = V8TestObj::toNative(info.Holder()); 548 548 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 549 if (!scriptContext)550 return v8Undefined();551 549 return toV8(imp->withScriptExecutionContextAttribute(scriptContext), info.Holder(), info.GetIsolate()); 552 550 } … … 558 556 TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0; 559 557 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 560 if (!scriptContext)561 return;562 558 imp->setWithScriptExecutionContextAttribute(scriptContext, WTF::getPtr(v)); 563 559 return; … … 603 599 ExceptionCode ec = 0; 604 600 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 605 if (!scriptContext)606 return v8Undefined();607 601 RefPtr<TestObj> v = imp->withScriptExecutionContextAttributeRaises(scriptContext, ec); 608 602 if (UNLIKELY(ec)) … … 618 612 ExceptionCode ec = 0; 619 613 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 620 if (!scriptContext)621 return;622 614 imp->setWithScriptExecutionContextAttributeRaises(scriptContext, WTF::getPtr(v), ec); 623 615 if (UNLIKELY(ec)) … … 634 626 return v8Undefined(); 635 627 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 636 if (!scriptContext)637 return v8Undefined();638 628 return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext), info.Holder(), info.GetIsolate()); 639 629 } … … 648 638 return; 649 639 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 650 if (!scriptContext)651 return;652 640 imp->setWithScriptExecutionContextAndScriptStateAttribute(state, scriptContext, WTF::getPtr(v)); 653 641 if (state.hadException()) … … 665 653 return v8Undefined(); 666 654 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 667 if (!scriptContext)668 return v8Undefined();669 655 RefPtr<TestObj> v = imp->withScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, ec); 670 656 if (UNLIKELY(ec)) … … 685 671 return; 686 672 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 687 if (!scriptContext)688 return;689 673 imp->setWithScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, WTF::getPtr(v), ec); 690 674 if (UNLIKELY(ec)) … … 703 687 return v8Undefined(); 704 688 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 705 if (!scriptContext)706 return v8Undefined();707 689 return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext), info.Holder(), info.GetIsolate()); 708 690 } … … 717 699 return; 718 700 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 719 if (!scriptContext)720 return;721 701 imp->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext, WTF::getPtr(v)); 722 702 if (state.hadException()) … … 1312 1292 TestObj* imp = V8TestObj::toNative(args.Holder()); 1313 1293 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 1314 if (!scriptContext)1315 return v8Undefined();1316 1294 imp->withScriptExecutionContext(scriptContext); 1317 1295 return v8Undefined(); … … 1324 1302 EmptyScriptState state; 1325 1303 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 1326 if (!scriptContext)1327 return v8Undefined();1328 1304 imp->withScriptExecutionContextAndScriptState(&state, scriptContext); 1329 1305 if (state.hadException()) … … 1340 1316 EmptyScriptState state; 1341 1317 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 1342 if (!scriptContext)1343 return v8Undefined();1344 1318 RefPtr<TestObj> result = imp->withScriptExecutionContextAndScriptStateObjException(&state, scriptContext, ec); 1345 1319 if (UNLIKELY(ec)) … … 1359 1333 EmptyScriptState state; 1360 1334 ScriptExecutionContext* scriptContext = getScriptExecutionContext(); 1361 if (!scriptContext)1362 return v8Undefined();1363 1335 RefPtr<TestObj> result = imp->withScriptExecutionContextAndScriptStateWithSpaces(&state, scriptContext); 1364 1336 if (state.hadException()) -
trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp
r127946 r128139 65 65 return args.Holder(); 66 66 67 // Get the script execution context.68 67 ScriptExecutionContext* context = getScriptExecutionContext(); 69 if (!context)70 return throwError(ReferenceError, "Blob constructor associated document is unavailable", args.GetIsolate());71 68 72 69 if (!args.Length()) { -
trunk/Source/WebCore/bindings/v8/custom/V8CustomXPathNSResolver.cpp
r126109 r128139 31 31 #include "V8CustomXPathNSResolver.h" 32 32 33 #include "Console.h" 34 #include "DOMWindow.h" 33 35 #include "ScriptCallStack.h" 34 36 #include "ScriptController.h" … … 67 69 68 70 if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) { 69 if (ScriptExecutionContext* context = getScriptExecutionContext()) 70 context->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method."); 71 activeDOMWindow(BindingState::instance())->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method."); 71 72 return String(); 72 73 } 73 74 74 75 // Catch exceptions from calling the namespace resolver. 75 v8::TryCatch try _catch;76 try _catch.SetVerbose(true);// Print exceptions to console.76 v8::TryCatch tryCatch; 77 tryCatch.SetVerbose(true); // Print exceptions to console. 77 78 78 79 const int argc = 1; … … 83 84 84 85 // Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR. 85 if (try _catch.HasCaught())86 if (tryCatch.HasCaught()) 86 87 return String(); 87 88 -
trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp
r127946 r128139 48 48 { 49 49 INC_STATS("DOM.MessageChannel.Constructor"); 50 // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject. 51 // Consider refactoring to reduce duplication. 50 52 51 if (!args.IsConstructCall()) 53 52 return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); … … 56 55 return args.Holder(); 57 56 58 // Get the ScriptExecutionContext (WorkerContext or Document)59 57 ScriptExecutionContext* context = getScriptExecutionContext(); 60 if (!context)61 return v8::Undefined();62 58 63 // Note: it's OK to let this RefPtr go out of scope because we also call64 // SetDOMWrapper(), which effectively holds a reference to obj.65 59 RefPtr<MessageChannel> obj = MessageChannel::create(context); 66 60 67 v8::Local<v8::Object> messageChannel= args.Holder();61 v8::Local<v8::Object> wrapper = args.Holder(); 68 62 69 63 // Create references from the MessageChannel wrapper to the two 70 64 // MessagePort wrappers to make sure that the MessagePort wrappers 71 65 // stay alive as long as the MessageChannel wrapper is around. 72 V8DOMWrapper::setNamedHiddenReference( messageChannel, "port1", toV8(obj->port1(), args.Holder(), args.GetIsolate()));73 V8DOMWrapper::setNamedHiddenReference( messageChannel, "port2", toV8(obj->port2(), args.Holder(), args.GetIsolate()));66 V8DOMWrapper::setNamedHiddenReference(wrapper, "port1", toV8(obj->port1(), args.Holder(), args.GetIsolate())); 67 V8DOMWrapper::setNamedHiddenReference(wrapper, "port2", toV8(obj->port2(), args.Holder(), args.GetIsolate())); 74 68 75 // Setup the standard wrapper object internal fields. 76 V8DOMWrapper::setDOMWrapper(messageChannel, &info, obj.get()); 77 V8DOMWrapper::setJSWrapperForDOMObject(obj.release(), messageChannel); 78 return messageChannel; 69 V8DOMWrapper::setDOMWrapper(wrapper, &info, obj.get()); 70 V8DOMWrapper::setJSWrapperForDOMObject(obj.release(), wrapper); 71 return wrapper; 79 72 } 80 73 81 82 74 } // namespace WebCore -
trunk/Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp
r126399 r128139 62 62 63 63 ScriptExecutionContext* context = getScriptExecutionContext(); 64 if (!context)65 return throwError(ReferenceError, "MutationObserver constructor's associated frame unavailable", args.GetIsolate());66 64 67 65 RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context); -
trunk/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp
r126399 r128139 90 90 91 91 ScriptExecutionContext* scriptExecutionContext = getScriptExecutionContext(); 92 if (!scriptExecutionContext)93 return v8::Undefined();94 92 95 93 RefPtr<SQLStatementCallback> callback; -
trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp
r126399 r128139 72 72 return throwError(SyntaxError, "Empty URL", args.GetIsolate()); 73 73 74 // Get the script execution context.75 74 ScriptExecutionContext* context = getScriptExecutionContext(); 76 if (!context)77 return throwError(ReferenceError, "WebSocket constructor's associated frame is not available", args.GetIsolate());78 79 75 const KURL& url = context->completeURL(toWebCoreString(urlstring)); 80 76 -
trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp
r126399 r128139 53 53 return args.Holder(); 54 54 55 // Expect no parameters.56 // Allocate a XMLHttpRequest object as its internal field.57 55 ScriptExecutionContext* context = getScriptExecutionContext(); 58 if (!context)59 return throwError(ReferenceError, "XMLHttpRequest constructor's associated context is not available", args.GetIsolate());60 56 61 57 RefPtr<SecurityOrigin> securityOrigin; 62 58 if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) 63 59 securityOrigin = isolatedContext->securityOrigin(); 60 64 61 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin); 62 65 63 v8::Handle<v8::Object> wrapper = args.Holder(); 66 64 V8DOMWrapper::setDOMWrapper(wrapper, &info, xmlHttpRequest.get()); -
trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
r127946 r128139 118 118 String method = toWebCoreString(args[0]); 119 119 String urlstring = toWebCoreString(args[1]); 120 120 121 ScriptExecutionContext* context = getScriptExecutionContext(); 121 if (!context)122 return v8::Undefined();123 124 122 KURL url = context->completeURL(urlstring); 125 123
Note: See TracChangeset
for help on using the changeset viewer.