Changeset 76224 in webkit


Ignore:
Timestamp:
Jan 20, 2011 4:31:18 AM (13 years ago)
Author:
yurys@chromium.org
Message:

2010-12-14 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Adam Barth.

[V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp
https://bugs.webkit.org/show_bug.cgi?id=51044

  • WebCore.gypi:
  • bindings/v8/V8ConsoleMessage.cpp: Removed.
  • bindings/v8/V8ConsoleMessage.h: Removed.
  • bindings/v8/V8DOMWindowShell.cpp: (WebCore::v8UncaughtExceptionHandler): (WebCore::reportUnsafeJavaScriptAccess): (WebCore::V8DOMWindowShell::initContextIfNeeded):
  • bindings/v8/V8Proxy.cpp: (WebCore::addMessageToConsole): (WebCore::logInfo): (WebCore::V8Proxy::reportUnsafeAccessTo): (WebCore::V8Proxy::runScript): (WebCore::V8Proxy::callFunction): (WebCore::V8Proxy::newInstance):
  • bindings/v8/V8Proxy.h:
  • bindings/v8/WorkerContextExecutionProxy.cpp:
  • bindings/v8/specialization/V8BindingState.cpp: (WebCore::::immediatelyReportUnsafeAccessTo):

2010-12-14 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Adam Barth.

[V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp
https://bugs.webkit.org/show_bug.cgi?id=51044

  • src/ChromeClientImpl.cpp: (WebKit::ChromeClientImpl::runJavaScriptAlert):
  • src/WebScriptController.cpp: (WebKit::WebScriptController::flushConsoleMessages):
Location:
trunk/Source
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76221 r76224  
     12010-12-14  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        [V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp
     6        https://bugs.webkit.org/show_bug.cgi?id=51044
     7
     8        * WebCore.gypi:
     9        * bindings/v8/V8ConsoleMessage.cpp: Removed.
     10        * bindings/v8/V8ConsoleMessage.h: Removed.
     11        * bindings/v8/V8DOMWindowShell.cpp:
     12        (WebCore::v8UncaughtExceptionHandler):
     13        (WebCore::reportUnsafeJavaScriptAccess):
     14        (WebCore::V8DOMWindowShell::initContextIfNeeded):
     15        * bindings/v8/V8Proxy.cpp:
     16        (WebCore::addMessageToConsole):
     17        (WebCore::logInfo):
     18        (WebCore::V8Proxy::reportUnsafeAccessTo):
     19        (WebCore::V8Proxy::runScript):
     20        (WebCore::V8Proxy::callFunction):
     21        (WebCore::V8Proxy::newInstance):
     22        * bindings/v8/V8Proxy.h:
     23        * bindings/v8/WorkerContextExecutionProxy.cpp:
     24        * bindings/v8/specialization/V8BindingState.cpp:
     25        (WebCore::::immediatelyReportUnsafeAccessTo):
     26
    1272011-01-19  MORITA Hajime  <morrita@google.com>
    228
  • trunk/Source/WebCore/WebCore.gypi

    r76216 r76224  
    950950            'bindings/v8/V8Collection.cpp',
    951951            'bindings/v8/V8Collection.h',
    952             'bindings/v8/V8ConsoleMessage.cpp',
    953             'bindings/v8/V8ConsoleMessage.h',
    954952            'bindings/v8/V8DataGridDataSource.cpp',
    955953            'bindings/v8/V8DataGridDataSource.h',
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r76207 r76224  
    4040#include "Page.h"
    4141#include "PageGroup.h"
     42#include "ScriptCallStack.h"
     43#include "ScriptCallStackFactory.h"
    4244#include "ScriptController.h"
    4345#include "StorageNamespace.h"
     
    4547#include "V8BindingState.h"
    4648#include "V8Collection.h"
    47 #include "V8ConsoleMessage.h"
    4849#include "V8DOMMap.h"
    4950#include "V8DOMWindow.h"
     
    9192}
    9293
     94static void v8UncaughtExceptionHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
     95{
     96    // Use the frame where JavaScript is called from.
     97    Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
     98    if (!frame)
     99        return;
     100
     101    v8::Handle<v8::String> errorMessageString = message->Get();
     102    ASSERT(!errorMessageString.IsEmpty());
     103    String errorMessage = toWebCoreString(errorMessageString);
     104
     105    v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
     106    RefPtr<ScriptCallStack> callStack;
     107    // Currently stack trace is only collected when inspector is open.
     108    if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
     109        callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
     110
     111    v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
     112    bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
     113    Document* document = frame->document();
     114    String resourceNameString = useURL ? document->url() : toWebCoreString(resourceName);
     115    document->reportException(errorMessage, message->GetLineNumber(), resourceNameString, callStack);
     116}
     117
    93118// Returns the owner frame pointer of a DOM wrapper object. It only works for
    94119// these DOM objects requiring cross-domain access check.
     
    118143    Frame* target = getTargetFrame(host, data);
    119144    if (target)
    120         V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportLater);
     145        V8Proxy::reportUnsafeAccessTo(target);
    121146}
    122147
     
    263288        v8::V8::SetGlobalGCEpilogueCallback(&V8GCController::gcEpilogue);
    264289
    265         v8::V8::AddMessageListener(&V8ConsoleMessage::handler);
     290        v8::V8::AddMessageListener(&v8UncaughtExceptionHandler);
    266291
    267292        v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess);
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r73605 r76224  
    5151#include "V8BindingState.h"
    5252#include "V8Collection.h"
    53 #include "V8ConsoleMessage.h"
    5453#include "V8DOMCoreException.h"
    5554#include "V8DOMMap.h"
     
    132131bool AllowAllocation::m_current = false;
    133132
     133static void addMessageToConsole(Page* page, const String& message, const String& sourceID, unsigned lineNumber)
     134{
     135    ASSERT(page);
     136    Console* console = page->mainFrame()->domWindow()->console();
     137    console->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, lineNumber, sourceID);
     138}
     139
    134140void logInfo(Frame* frame, const String& message, const String& url)
    135141{
     
    137143    if (!page)
    138144        return;
    139     V8ConsoleMessage consoleMessage(message, url, 0);
    140     consoleMessage.dispatchNow(page);
    141 }
    142 
    143 enum DelayReporting {
    144     ReportLater,
    145     ReportNow
    146 };
    147 
    148 void V8Proxy::reportUnsafeAccessTo(Frame* target, DelayReporting delay)
     145    addMessageToConsole(page, message, url, 0);
     146}
     147
     148void V8Proxy::reportUnsafeAccessTo(Frame* target)
    149149{
    150150    ASSERT(target);
     
    167167    const String kSourceID = "";
    168168    const int kLineNumber = 1;
    169     V8ConsoleMessage message(str, kSourceID, kLineNumber);
    170 
    171     if (delay == ReportNow) {
    172         // NOTE: Safari prints the message in the target page, but it seems like
    173         // it should be in the source page. Even for delayed messages, we put it in
    174         // the source page; see V8ConsoleMessage::processDelayed().
    175         message.dispatchNow(source->page());
    176     } else {
    177         ASSERT(delay == ReportLater);
    178         // We cannot safely report the message eagerly, because this may cause
    179         // allocations and GCs internally in V8 and we cannot handle that at this
    180         // point. Therefore we delay the reporting.
    181         message.dispatchLater();
    182     }
     169
     170    // NOTE: Safari prints the message in the target page, but it seems like
     171    // it should be in the source page. Even for delayed messages, we put it in
     172    // the source page.
     173    addMessageToConsole(source->page(), str, kSourceID, kLineNumber);
    183174}
    184175
     
    413404    v8::Local<v8::Value> result;
    414405    {
    415         V8ConsoleMessage::Scope scope;
    416 
    417406        // See comment in V8Proxy::callFunction.
    418407        m_frame->keepAlive();
     
    447436    v8::Local<v8::Value> result;
    448437    {
    449         V8ConsoleMessage::Scope scope;
    450 
    451438        if (m_recursion >= kMaxRecursionDepth) {
    452439            v8::Local<v8::String> code = v8::String::New("throw new RangeError('Maximum call stack size exceeded.')");
     
    512499    v8::Local<v8::Value> result;
    513500    {
    514         V8ConsoleMessage::Scope scope;
    515 
    516501        // See comment in V8Proxy::callFunction.
    517502        m_frame->keepAlive();
     
    775760}
    776761
    777 void V8Proxy::processConsoleMessages()
    778 {
    779     V8ConsoleMessage::processDelayed();
    780 }
    781 
    782762void V8Proxy::registerExtensionWithV8(v8::Extension* extension)
    783763{
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r72387 r76224  
    133133        };
    134134
    135         // When to report errors.
    136         enum DelayReporting {
    137             ReportLater,
    138             ReportNow
    139         };
    140 
    141135        explicit V8Proxy(Frame*);
    142136
     
    264258        static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*);
    265259
    266         // Process any pending JavaScript console messages.
    267         static void processConsoleMessages();
    268 
    269260        v8::Local<v8::Context> context();
    270261        v8::Local<v8::Context> mainWorldContext();
     
    287278
    288279        // Report an unsafe attempt to access the given frame on the console.
    289         static void reportUnsafeAccessTo(Frame* target, DelayReporting delay);
     280        static void reportUnsafeAccessTo(Frame* target);
    290281
    291282    private:
  • trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

    r76216 r76224  
    4242#include "SharedWorkerContext.h"
    4343#include "V8Binding.h"
    44 #include "V8ConsoleMessage.h"
    4544#include "V8DOMMap.h"
    4645#include "V8DedicatedWorkerContext.h"
  • trunk/Source/WebCore/bindings/v8/specialization/V8BindingState.cpp

    r74449 r76224  
    8282void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target)
    8383{
    84     V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportNow);
     84    V8Proxy::reportUnsafeAccessTo(target);
    8585}
    8686
  • trunk/Source/WebKit/chromium/ChangeLog

    r76216 r76224  
     12010-12-14  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        [V8] Get rid of delayed exception reporting in V8ConsoleMessage.cpp
     6        https://bugs.webkit.org/show_bug.cgi?id=51044
     7
     8        * src/ChromeClientImpl.cpp:
     9        (WebKit::ChromeClientImpl::runJavaScriptAlert):
     10        * src/WebScriptController.cpp:
     11        (WebKit::WebScriptController::flushConsoleMessages):
     12
    1132010-12-27  Yury Semikhatsky  <yurys@chromium.org>
    214
  • trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp

    r76198 r76224  
    437437{
    438438    if (m_webView->client()) {
    439 #if USE(V8)
    440         // Before showing the JavaScript dialog, we give the proxy implementation
    441         // a chance to process any pending console messages.
    442         V8Proxy::processConsoleMessages();
    443 #endif
    444439        m_webView->client()->runModalAlertDialog(
    445440            WebFrameImpl::fromFrame(frame), message);
  • trunk/Source/WebKit/chromium/src/WebScriptController.cpp

    r68666 r76224  
    5555void WebScriptController::flushConsoleMessages()
    5656{
    57     WebCore::V8Proxy::processConsoleMessages();
     57    // FIXME: remove this method after all it's usages are gone.
    5858}
    5959
Note: See TracChangeset for help on using the changeset viewer.