Changeset 94488 in webkit


Ignore:
Timestamp:
Sep 3, 2011 8:57:04 AM (13 years ago)
Author:
mitz@apple.com
Message:

Move testStringByEvaluatingJavaScriptFromString() from DumpRenderTree to TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=67559

Reviewed by Darin Adler.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(dumpRenderTree): Moved testStringByEvaluatingJavaScriptFromString() from here and removed
the call to it.

  • TestWebKitAPI/PlatformUtilities.h: Declared Util::toSTD(NSString *)
  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added StringByEvaluatingJavaScriptFromString.mm.
  • TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm: Added.

(TestWebKitAPI::TEST): Added. Moved testStringByEvaluatingJavaScriptFromString() to here.

  • TestWebKitAPI/mac/PlatformUtilitiesMac.mm:

(TestWebKitAPI::Util::toSTD): Added.

Location:
trunk/Tools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r94487 r94488  
     12011-09-03  Dan Bernstein  <mitz@apple.com>
     2
     3        Move testStringByEvaluatingJavaScriptFromString() from DumpRenderTree to TestWebKitAPI
     4        https://bugs.webkit.org/show_bug.cgi?id=67559
     5
     6        Reviewed by Darin Adler.
     7
     8        * DumpRenderTree/mac/DumpRenderTree.mm:
     9        (dumpRenderTree): Moved testStringByEvaluatingJavaScriptFromString() from here and removed
     10        the call to it.
     11        * TestWebKitAPI/PlatformUtilities.h: Declared Util::toSTD(NSString *)
     12        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added StringByEvaluatingJavaScriptFromString.mm.
     13        * TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm: Added.
     14        (TestWebKitAPI::TEST): Added. Moved testStringByEvaluatingJavaScriptFromString() to here.
     15        * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
     16        (TestWebKitAPI::Util::toSTD): Added.
     17
    1182011-09-03  Adam Barth  <abarth@webkit.org>
    219
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r94093 r94488  
    336336}
    337337
    338 void testStringByEvaluatingJavaScriptFromString()
    339 {
    340     // maps expected result <= JavaScript expression
    341     NSDictionary *expressions = [NSDictionary dictionaryWithObjectsAndKeys:
    342         @"0", @"0",
    343         @"0", @"'0'",
    344         @"", @"",
    345         @"", @"''",
    346         @"", @"new String()",
    347         @"", @"new String('0')",
    348         @"", @"throw 1",
    349         @"", @"{ }",
    350         @"", @"[ ]",
    351         @"", @"//",
    352         @"", @"a.b.c",
    353         @"", @"(function() { throw 'error'; })()",
    354         @"", @"null",
    355         @"", @"undefined",
    356         @"true", @"true",
    357         @"false", @"false",
    358         @"", @"alert('Should not be result')",
    359         nil
    360     ];
    361 
    362     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    363     WebView *webView = [[WebView alloc] initWithFrame:NSZeroRect frameName:@"" groupName:@""];
    364 
    365     NSEnumerator *enumerator = [expressions keyEnumerator];
    366     id expression;
    367     while ((expression = [enumerator nextObject])) {
    368         NSString *expectedResult = [expressions objectForKey:expression];
    369         NSString *result = [webView stringByEvaluatingJavaScriptFromString:expression];
    370         assert([result isEqualToString:expectedResult]);
    371     }
    372 
    373     [webView close];
    374     [webView release];
    375     [pool release];
    376 }
    377 
    378338static NSString *libraryPathForDumpRenderTree()
    379339{
     
    673633    [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"localhost"];
    674634    [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"127.0.0.1"];
    675 
    676     // <rdar://problem/5222911>
    677     testStringByEvaluatingJavaScriptFromString();
    678635
    679636    // http://webkit.org/b/32689
  • trunk/Tools/TestWebKitAPI/PlatformUtilities.h

    r93404 r94488  
    3030#include <string>
    3131
     32#if PLATFORM(MAC)
     33#if __OBJC__
     34@class NSString;
     35#else
     36class NSString;
     37#endif
     38#endif
     39
    3240namespace TestWebKitAPI {
    3341namespace Util {
     
    5563std::string toSTD(WKRetainPtr<WKStringRef>);
    5664std::string toSTD(const char*);
     65#if PLATFORM(MAC)
     66std::string toSTD(NSString *);
     67#endif
    5768
    5869WKRetainPtr<WKStringRef> toWK(const char* utf8String);
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r94437 r94488  
    2020                33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
    2121                37200B9213A16230007A4FAD /* VectorReverse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37200B9113A16230007A4FAD /* VectorReverse.cpp */; };
     22                3799AD3A14120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */; };
    2223                37DC678D140D7C5000ABCCDB /* DOMRangeOfString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */; };
    2324                37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */; };
     
    137138                33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
    138139                37200B9113A16230007A4FAD /* VectorReverse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VectorReverse.cpp; path = WTF/VectorReverse.cpp; sourceTree = "<group>"; };
     140                3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringByEvaluatingJavaScriptFromString.mm; sourceTree = "<group>"; };
    139141                37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMRangeOfString.mm; sourceTree = "<group>"; };
    140142                37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DOMRangeOfString.html; sourceTree = "<group>"; };
     
    417419                                C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
    418420                                939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
     421                                3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */,
    419422                        );
    420423                        path = mac;
     
    567570                                A7A966DB140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp in Sources */,
    568571                                939BA91714103412001A01BD /* DeviceScaleFactorOnBack.mm in Sources */,
     572                                3799AD3A14120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm in Sources */,
    569573                        );
    570574                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Tools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm

    r93404 r94488  
    3030#include <WebKit2/WKURLCF.h>
    3131#include <WebKit2/WKURLResponseNS.h>
     32#include <wtf/OwnArrayPtr.h>
    3233#include <wtf/RetainPtr.h>
    3334
     
    7576}
    7677
     78std::string toSTD(NSString *string)
     79{
     80    size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
     81    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
     82    size_t stringLength;
     83    [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0];
     84    return std::string(buffer.get(), stringLength);
     85}
     86
    7787} // namespace Util
    7888} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.