Changeset 70658 in webkit


Ignore:
Timestamp:
Oct 27, 2010 9:56:02 AM (14 years ago)
Author:
bweinstein@apple.com
Message:

WebKit2 shouldn't try to send an empty user agent
https://bugs.webkit.org/show_bug.cgi?id=48397

Reviewed by Adam Roben.

WebKit2:

Change the check of the custom user agent to an empty check instead of a null check. When the client application
sets a custom user agent and then resets it, the custom user agent is set to an empty string. If all we do
is check for a null string, then we will think we have a custom user agent (which is empty) and send an empty
user agent.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::userAgent):

WebKitTools:

Add a test that when we set our custom user agent to an empty string, we don't send
an empty user agent.

  • TestWebKitAPI/Tests/WebKit2/PreventEmptyUserAgent.cpp: Added.

(TestWebKitAPI::didRunJavaScript): Make sure that the result of navigator.userAgent isn't empty.
(TestWebKitAPI::TEST): Set our custom user agent to the empty string, and run navigator.userAgent.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add the new file.
  • TestWebKitAPI/win/TestWebKitAPI.vcproj: Ditto.
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r70653 r70658  
     12010-10-26  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        WebKit2 shouldn't try to send an empty user agent
     6        https://bugs.webkit.org/show_bug.cgi?id=48397
     7       
     8        Change the check of the custom user agent to an empty check instead of a null check. When the client application
     9        sets a custom user agent and then resets it, the custom user agent is set to an empty string. If all we do
     10        is check for a null string, then we will think we have a custom user agent (which is empty) and send an empty
     11        user agent.
     12
     13        * WebProcess/WebPage/WebPage.cpp:
     14        (WebKit::WebPage::userAgent):
     15
    1162010-10-27  Adam Roben  <aroben@apple.com>
    217
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r70585 r70658  
    665665String WebPage::userAgent() const
    666666{
    667     if (!m_customUserAgent.isNull())
     667    if (!m_customUserAgent.isEmpty())
    668668        return m_customUserAgent;
    669669
  • trunk/WebKitTools/ChangeLog

    r70655 r70658  
     12010-10-26  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        WebKit2 shouldn't try to send an empty user agent
     6        https://bugs.webkit.org/show_bug.cgi?id=48397
     7       
     8        Add a test that when we set our custom user agent to an empty string, we don't send
     9        an empty user agent.
     10
     11        * TestWebKitAPI/Tests/WebKit2/PreventEmptyUserAgent.cpp: Added.
     12        (TestWebKitAPI::didRunJavaScript): Make sure that the result of navigator.userAgent isn't empty.
     13        (TestWebKitAPI::TEST): Set our custom user agent to the empty string, and run navigator.userAgent.
     14       
     15        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add the new file.
     16        * TestWebKitAPI/win/TestWebKitAPI.vcproj: Ditto.
     17
    1182010-10-27  Adam Roben  <aroben@apple.com>
    219
  • trunk/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r70352 r70658  
    1111                1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; };
    1212                1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */; };
     13                333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */; };
    1314                BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
    1415                BC131A9B1171316900B69727 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131A9A1171316900B69727 /* main.mm */; };
     
    8485                1A02C84E125D4A8400E3F4BD /* Find.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Find.cpp; sourceTree = "<group>"; };
    8586                1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EvaluateJavaScript.cpp; sourceTree = "<group>"; };
     87                333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
    8688                8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
    8789                BC131883117114A800B69727 /* PlatformUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUtilities.h; sourceTree = "<group>"; };
     
    231233                                BCBD3760125ABCFE00D2C29F /* FrameMIMETypePNG.cpp */,
    232234                                BC909779125571AB00083756 /* PageLoadBasic.cpp */,
     235                                333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
    233236                                C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
    234237                                BC90995D12567BC100083756 /* WKString.cpp */,
     
    378381                                BCB68040126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp in Sources */,
    379382                                1A5FEFDD1270E2A3000E2921 /* EvaluateJavaScript.cpp in Sources */,
     383                                333B9CE21277F23100FEFCE3 /* PreventEmptyUserAgent.cpp in Sources */,
    380384                        );
    381385                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj

    r70267 r70658  
    450450                                </File>
    451451                                <File
     452                                        RelativePath="..\Tests\WebKit2\PreventEmptyUserAgent.cpp"
     453                                        >
     454                                </File>
     455                                <File
    452456                                        RelativePath="..\Tests\WebKit2\simple.html"
    453457                                        >
Note: See TracChangeset for help on using the changeset viewer.