Unreviewed, rolling out r154640.

http://trac.webkit.org/changeset/154640
https://bugs.webkit.org/show_bug.cgi?id=120329

Caused flaky crashes on a lot of editing tests (Requested by
rniwa on #webkit).

* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/mac/PoseAsClass.h: Removed.
* WebKitTestRunner/mac/PoseAsClass.mm: Removed.
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformInitialize):
(WTR::TestController::platformDestroy):
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h: Removed.
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: Removed.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f5e5752d
2013-08-26 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r154640.
http://trac.webkit.org/changeset/154640
https://bugs.webkit.org/show_bug.cgi?id=120329
Caused flaky crashes on a lot of editing tests (Requested by
rniwa on #webkit).
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/mac/PoseAsClass.h: Removed.
* WebKitTestRunner/mac/PoseAsClass.mm: Removed.
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformInitialize):
(WTR::TestController::platformDestroy):
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.h: Removed.
* WebKitTestRunner/mac/WebKitTestRunnerPasteboard.mm: Removed.
2013-08-26 Dan Bernstein <mitz@apple.com>
Automatic bug reports case pain
......
......@@ -86,8 +86,6 @@
BCDA2B9A1191051F00C3BC47 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */; };
C0CE720B1247C93300BC0EC4 /* TestRunnerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0CE720A1247C93300BC0EC4 /* TestRunnerMac.mm */; };
E1BA671E1742DA6A00C20251 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E1BA671D1742DA5A00C20251 /* Carbon.framework */; };
E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */; };
E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -222,10 +220,6 @@
BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C0CE720A1247C93300BC0EC4 /* TestRunnerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestRunnerMac.mm; path = mac/TestRunnerMac.mm; sourceTree = "<group>"; };
E1BA671D1742DA5A00C20251 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PoseAsClass.mm; sourceTree = "<group>"; };
E1C642C217CBCC7300D66A3C /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoseAsClass.h; sourceTree = "<group>"; };
E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerPasteboard.mm; sourceTree = "<group>"; };
E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerPasteboard.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -422,11 +416,7 @@
5670B8271386FCA5002EB355 /* EventSenderProxy.mm */,
BC7933FF118F7C84005EA8E2 /* main.mm */,
BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
E1C642C217CBCC7300D66A3C /* PoseAsClass.h */,
BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */,
E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */,
);
path = mac;
sourceTree = "<group>";
......@@ -612,12 +602,10 @@
buildActionMask = 2147483647;
files = (
5322FB4313FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp in Sources */,
E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */,
5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */,
BC793400118F7C84005EA8E2 /* main.mm in Sources */,
5322FB4613FDA0EA0041ABCC /* PixelDumpSupport.cpp in Sources */,
E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */,
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
......
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PoseAsClass_h
#define PoseAsClass_h
void poseAsClass(const char* imposter, const char* original);
#endif // PoseAsClass_h
/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PoseAsClass.h"
#import <objc/runtime.h>
#import <wtf/Assertions.h>
static void swizzleAllMethods(Class imposter, Class original)
{
unsigned imposterMethodCount;
Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount);
unsigned originalMethodCount;
Method* originalMethods = class_copyMethodList(original, &originalMethodCount);
for (unsigned i = 0; i < imposterMethodCount; i++) {
SEL imposterMethodName = method_getName(imposterMethods[i]);
// Attempt to add the method to the original class. If it fails, the method already exists and we should
// instead exchange the implementations.
if (class_addMethod(original, imposterMethodName, method_getImplementation(imposterMethods[i]), method_getTypeEncoding(imposterMethods[i])))
continue;
unsigned j = 0;
for (; j < originalMethodCount; j++) {
SEL originalMethodName = method_getName(originalMethods[j]);
if (sel_isEqual(imposterMethodName, originalMethodName))
break;
}
// If class_addMethod failed above then the method must exist on the original class.
ASSERT(j < originalMethodCount);
method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
}
free(imposterMethods);
free(originalMethods);
}
void poseAsClass(const char* imposter, const char* original)
{
Class imposterClass = objc_getClass(imposter);
Class originalClass = objc_getClass(original);
// Swizzle instance methods
swizzleAllMethods(imposterClass, originalClass);
// and then class methods
swizzleAllMethods(object_getClass(imposterClass), object_getClass(originalClass));
}
......@@ -27,8 +27,6 @@
#import "TestController.h"
#import "PlatformWebView.h"
#import "PoseAsClass.h"
#import "WebKitTestRunnerPasteboard.h"
#import <WebKit2/WKStringCF.h>
#import <mach-o/dyld.h>
......@@ -40,12 +38,10 @@ void TestController::notifyDone()
void TestController::platformInitialize()
{
poseAsClass("WebKitTestRunnerPasteboard", "NSPasteboard");
}
void TestController::platformDestroy()
{
[WebKitTestRunnerPasteboard releaseLocalPasteboards];
}
void TestController::initializeInjectedBundlePath()
......
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebKitTestRunnerPasteboard_h
#define WebKitTestRunnerPasteboard_h
#import <AppKit/AppKit.h>
@interface WebKitTestRunnerPasteboard : NSPasteboard
+ (void)releaseLocalPasteboards;
@end
#endif // WebKitTestRunnerPasteboard_h
/*
* Copyright (C) 2005, 2006, 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebKitTestRunnerPasteboard.h"
@interface LocalPasteboard : NSPasteboard
{
NSMutableArray *typesArray;
NSMutableSet *typesSet;
NSMutableDictionary *dataByType;
NSInteger changeCount;
NSString *pasteboardName;
}
-(id)initWithName:(NSString *)name;
@end
static NSMutableDictionary *localPasteboards;
@implementation WebKitTestRunnerPasteboard
// Return a local pasteboard so we don't disturb the real pasteboards when running tests.
+ (NSPasteboard *)_pasteboardWithName:(NSString *)name
{
static int number = 0;
if (!name)
name = [NSString stringWithFormat:@"LocalPasteboard%d", ++number];
if (!localPasteboards)
localPasteboards = [[NSMutableDictionary alloc] init];
LocalPasteboard *pasteboard = [localPasteboards objectForKey:name];
if (pasteboard)
return pasteboard;
pasteboard = [[LocalPasteboard alloc] initWithName:name];
[localPasteboards setObject:pasteboard forKey:name];
[pasteboard release];
return pasteboard;
}
+ (void)releaseLocalPasteboards
{
[localPasteboards release];
localPasteboards = nil;
}
@end
@implementation LocalPasteboard
+ (id)alloc
{
return NSAllocateObject(self, 0, 0);
}
- (id)initWithName:(NSString *)name
{
typesArray = [[NSMutableArray alloc] init];
typesSet = [[NSMutableSet alloc] init];
dataByType = [[NSMutableDictionary alloc] init];
pasteboardName = [name copy];
return self;
}
- (void)dealloc
{
[typesArray release];
[typesSet release];
[dataByType release];
[pasteboardName release];
[super dealloc];
}
- (NSString *)name
{
return pasteboardName;
}
- (void)releaseGlobally
{
}
- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner
{
[typesArray removeAllObjects];
[typesSet removeAllObjects];
[dataByType removeAllObjects];
return [self addTypes:newTypes owner:newOwner];
}
- (NSInteger)addTypes:(NSArray *)newTypes owner:(id)newOwner
{
unsigned count = [newTypes count];
unsigned i;
for (i = 0; i < count; ++i) {
NSString *type = [newTypes objectAtIndex:i];
NSString *setType = [typesSet member:type];
if (!setType) {
setType = [type copy];
[typesArray addObject:setType];
[typesSet addObject:setType];
[setType release];
}
if (newOwner && [newOwner respondsToSelector:@selector(pasteboard:provideDataForType:)])
[newOwner pasteboard:self provideDataForType:setType];
}
return ++changeCount;
}
- (NSInteger)changeCount
{
return changeCount;
}
- (NSArray *)types
{
return typesArray;
}
- (NSString *)availableTypeFromArray:(NSArray *)types
{
unsigned count = [types count];
unsigned i;
for (i = 0; i < count; ++i) {
NSString *type = [types objectAtIndex:i];
NSString *setType = [typesSet member:type];
if (setType)
return setType;
}
return nil;
}
- (BOOL)setData:(NSData *)data forType:(NSString *)dataType
{
if (!data)
data = [NSData data];
if (![typesSet containsObject:dataType])
return NO;
[dataByType setObject:data forKey:dataType];
++changeCount;
return YES;
}
- (NSData *)dataForType:(NSString *)dataType
{
return [dataByType objectForKey:dataType];
}
- (BOOL)setPropertyList:(id)propertyList forType:(NSString *)dataType
{
CFDataRef data = 0;
if (propertyList)
data = CFPropertyListCreateXMLData(0, propertyList);
BOOL result = [self setData:(NSData *)data forType:dataType];
if (data)
CFRelease(data);
return result;
}
- (BOOL)setString:(NSString *)string forType:(NSString *)dataType
{
CFDataRef data = 0;
if (string) {
if (![string length])
data = CFDataCreate(0, 0, 0);
else
data = CFStringCreateExternalRepresentation(0, (CFStringRef)string, kCFStringEncodingUTF8, 0);
}
BOOL result = [self setData:(NSData *)data forType:dataType];
if (data)
CFRelease(data);
return result;
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment