Changeset 70267 in webkit


Ignore:
Timestamp:
Oct 21, 2010 2:46:10 PM (14 years ago)
Author:
andersca@apple.com
Message:

Crash evaluating JavaScript string that throws an exception
https://bugs.webkit.org/show_bug.cgi?id=48092
<rdar://problem/8487657>

Reviewed by Adam Roben.

WebKit2:

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::sendMessage):
m_connection can be null here; just return false if that is the case.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::runJavaScriptInMainFrame):
If the JSValue returned is null we just send along a null string.

WebKitTools:

Add a test that evaluates a JavaScript string that throws an exception and check that
the callback is called.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp: Added.

(TestWebKitAPI::didRunJavaScript):
(TestWebKitAPI::WebKit2_EvaluateJavaScript):

  • TestWebKitAPI/win/TestWebKitAPI.vcproj:
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r70265 r70267  
     12010-10-21  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Crash evaluating JavaScript string that throws an exception
     6        https://bugs.webkit.org/show_bug.cgi?id=48092
     7        <rdar://problem/8487657>
     8
     9        * UIProcess/WebProcessProxy.cpp:
     10        (WebKit::WebProcessProxy::sendMessage):
     11        m_connection can be null here; just return false if that is the case.
     12   
     13        * WebProcess/WebPage/WebPage.cpp:
     14        (WebKit::WebPage::runJavaScriptInMainFrame):
     15        If the JSValue returned is null we just send along a null string.
     16
    1172010-10-21  Adam Roben  <aroben@apple.com>
    218
  • trunk/WebKit2/UIProcess/WebProcessProxy.cpp

    r69056 r70267  
    106106        return true;
    107107    }
    108    
     108
     109    // If the web process has exited, m_connection will be null here.
     110    if (!m_connection)
     111        return false;
     112
    109113    return m_connection->sendMessage(messageID, arguments);
    110114}
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r70255 r70267  
    683683    JSLock lock(SilenceAssertionsOnly);
    684684    JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue();
    685     String resultString = ustringToString(resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));
     685    String resultString;
     686    if (resultValue)
     687        resultString = ustringToString(resultValue.toString(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec()));
    686688
    687689    WebProcess::shared().connection()->send(Messages::WebPageProxy::DidRunJavaScriptInMainFrame(resultString, callbackID), m_pageID);
  • trunk/WebKitTools/ChangeLog

    r70265 r70267  
     12010-10-21  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Crash evaluating JavaScript string that throws an exception
     6        https://bugs.webkit.org/show_bug.cgi?id=48092
     7        <rdar://problem/8487657>
     8
     9        Add a test that evaluates a JavaScript string that throws an exception and check that
     10        the callback is called.
     11
     12        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     13        * TestWebKitAPI/Tests/WebKit2/EvaluateJavaScript.cpp: Added.
     14        (TestWebKitAPI::didRunJavaScript):
     15        (TestWebKitAPI::WebKit2_EvaluateJavaScript):
     16        * TestWebKitAPI/win/TestWebKitAPI.vcproj:
     17
    1182010-10-21  Adam Roben  <aroben@apple.com>
    219
  • trunk/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r70244 r70267  
    1010                1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; };
    1111                1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; };
     12                1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */; };
    1213                BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
    1314                BC131A9B1171316900B69727 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131A9A1171316900B69727 /* main.mm */; };
     
    8283                1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; };
    8384                1A02C84E125D4A8400E3F4BD /* Find.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Find.cpp; sourceTree = "<group>"; };
     85                1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EvaluateJavaScript.cpp; sourceTree = "<group>"; };
    8486                8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
    8587                BC131883117114A800B69727 /* PlatformUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUtilities.h; sourceTree = "<group>"; };
     
    224226                        children = (
    225227                                BC90977B125571AE00083756 /* Resources */,
     228                                1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */,
    226229                                1A02C84E125D4A8400E3F4BD /* Find.cpp */,
    227230                                BCBD370F125AA2EB00D2C29F /* FrameMIMETypeHTML.cpp */,
     
    374377                                BC575BC0126F5752006F0F12 /* PlatformUtilities.cpp in Sources */,
    375378                                BCB68040126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp in Sources */,
     379                                1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */,
    376380                        );
    377381                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj

    r70247 r70267  
    418418                                >
    419419                                <File
     420                                        RelativePath="..\Tests\WebKit2\EvaluateJavaScript.cpp"
     421                                        >
     422                                </File>
     423                                <File
    420424                                        RelativePath="..\Tests\WebKit2\FailedLoad.cpp"
    421425                                        >
Note: See TracChangeset for help on using the changeset viewer.