+2007-05-16 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Justin.
+
+ - added a bunch of layout tests using the new load delegate testing mechanism
+
+ * http/tests/loading/bad-scheme-subframe-expected.txt: Added.
+ * http/tests/loading/bad-scheme-subframe.html: Added.
+ * http/tests/loading/bad-server-subframe-expected.txt: Added.
+ * http/tests/loading/bad-server-subframe.html: Added.
+ * http/tests/loading/basic-expected.txt: Added.
+ * http/tests/loading/basic.html: Added.
+ * http/tests/loading/empty-subframe-expected.txt: Added.
+ * http/tests/loading/empty-subframe.html: Added.
+ * http/tests/loading/simple-subframe-expected.txt: Added.
+ * http/tests/loading/simple-subframe.html: Added.
+
2007-05-16 dethbakin <bdakin@apple.com>
Reviewed by Hyatt.
--- /dev/null
+main frame - didStartProvisionalLoadForFrame
+main frame - didFirstLayoutInFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+frame "f1" - didClearWindowObjectForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "f1" - didFirstLayoutInFrame
+frame "f1" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+main frame - didFirstLayoutInFrame
+This is a test of load callbacks. It is only useful inside the regression test tool.
+
--- /dev/null
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+This is a test of load callbacks. It is only useful inside the regression test tool.<br>
+<iframe name="f1" src="this-is-definitely-a-bad-uri-scheme:"></iframe>
--- /dev/null
+main frame - didStartProvisionalLoadForFrame
+frame "f1" - willCloseFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+frame "f1" - didClearWindowObjectForFrame
+frame "f1" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "f1" - didFirstLayoutInFrame
+main frame - didFirstLayoutInFrame
+frame "f1" - didFailProvisionalLoadWithError
+main frame - didFinishLoadForFrame
+This is a test of load callbacks. It is only useful inside the regression test tool.
+It also assumes there is no web server running locally on port 54321.
+
--- /dev/null
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+This is a test of load callbacks. It is only useful inside the regression test tool.<br>
+It also assumes there is no web server running locally on port 54321.<br>
+<iframe name="f1" src="http://localhost:54321"></iframe>
--- /dev/null
+main frame - didStartProvisionalLoadForFrame
+frame "f1" - willCloseFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFirstLayoutInFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didFinishLoadForFrame
+This is a test of load callbacks. It is only useful inside the regression test tool.
--- /dev/null
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+This is a test of load callbacks. It is only useful inside the regression test tool.
--- /dev/null
+main frame - didStartProvisionalLoadForFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+frame "f1" - didClearWindowObjectForFrame
+frame "f1" - didStartProvisionalLoadForFrame
+frame "f1" - willCloseFrame
+frame "f1" - didCommitLoadForFrame
+frame "f1" - didClearWindowObjectForFrame
+frame "f1" - didHandleOnloadEventsForFrame
+frame "f1" - didFinishDocumentLoadForFrame
+frame "f1" - didFinishLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "f1" - didFirstLayoutInFrame
+main frame - didFirstLayoutInFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didFinishLoadForFrame
+This is a test of load callbacks. It is only useful inside the regression test tool.
+
--- /dev/null
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+This is a test of load callbacks. It is only useful inside the regression test tool.<br>
+<iframe name="f1"></iframe>
--- /dev/null
+main frame - didStartProvisionalLoadForFrame
+frame "f1" - willCloseFrame
+main frame - willCloseFrame
+main frame - didCommitLoadForFrame
+main frame - didClearWindowObjectForFrame
+frame "f1" - didClearWindowObjectForFrame
+frame "f1" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "f1" - willCloseFrame
+frame "f1" - didCommitLoadForFrame
+frame "f1" - didClearWindowObjectForFrame
+frame "f1" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "f1" - didFirstLayoutInFrame
+main frame - didFirstLayoutInFrame
+frame "f1" - didFinishDocumentLoadForFrame
+frame "f1" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderText {#text} at (0,0) size 482x18
+ text run at (0,0) width 482: "This is a test of load callbacks. It is only useful inside the regression test tool."
+ RenderBR {BR} at (482,14) size 0x0
+ RenderPartObject {IFRAME} at (0,18) size 304x154 [border: (2px inset #000000)]
+ layer at (0,0) size 300x150
+ RenderView at (0,0) size 300x150
+ layer at (0,0) size 300x150
+ RenderBlock {HTML} at (0,0) size 300x150
+ RenderBody {BODY} at (8,8) size 284x134
+ RenderInline {B} at (0,0) size 23x18
+ RenderText {#text} at (0,0) size 23x18
+ text run at (0,0) width 23: "test"
+ RenderText {#text} at (0,0) size 0x0
--- /dev/null
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpFrameLoadCallbacks();
+</script>
+This is a test of load callbacks. It is only useful inside the regression test tool.<br>
+<iframe name="f1" src="data:text/html,<b>test</b>"></iframe>
+2007-05-16 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Justin.
+
+ - created a new mechanism to log FrameLoadDelegate callbacks in directories named "loading"
+
+ The reason for doing things in this slightly odd way is to make sure we don't miss the load delegates
+ that happen before the load commits.
+
+ Basically I moved WaitUntilDoneDelegate into a separate file (FrameLoadDelegate.m) and added
+ optional logging for every FrameLoadDelegate callback, including SPI callbacks.
+
+ * DumpRenderTree/DumpRenderTree.h:
+ * DumpRenderTree/DumpRenderTree.m:
+ (createWebView):
+ (dumpRenderTree):
+ (dump):
+ (+[LayoutTestController isSelectorExcludedFromWebScript:]):
+ (-[LayoutTestController clearBackForwardList]):
+ (-[LayoutTestController setUseDashboardCompatibilityMode:]):
+ (-[LayoutTestController dumpFrameLoadCallbacks]):
+ (-[LayoutTestController setWindowIsKey:]):
+ (-[LayoutTestController setMainFrameIsFirstResponder:]):
+ (-[LayoutTestController _doLoad:target:]):
+ (-[LayoutTestController _doBackOrForwardNavigation:]):
+ (-[LayoutTestController queueReload]):
+ (-[LayoutTestController queueScript:]):
+ (-[LayoutTestController queueLoad:target:]):
+ (-[LayoutTestController setAcceptsEditing:]):
+ (-[LayoutTestController setTabKeyCyclesThroughElements:]):
+ (shouldLogFrameLoadDelegates):
+ (runTest):
+ (displayWebView):
+ (+[DumpRenderTreeEvent mouseLocation]):
+ * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+ * DumpRenderTree/DumpRenderTreeDraggingInfo.m:
+ (-[DumpRenderTreeDraggingInfo draggingDestinationWindow]):
+ * DumpRenderTree/EventSendingController.m:
+ (-[EventSendingController mouseDown]):
+ (-[EventSendingController mouseUp]):
+ (-[EventSendingController mouseMoveToX:Y:]):
+ (-[EventSendingController contextClick]):
+ * DumpRenderTree/FrameLoadDelegate.h: Added.
+ * DumpRenderTree/FrameLoadDelegate.m: Added.
+ (-[WebFrame _drt_descriptionSuitableForTestResult]):
+ (-[FrameLoadDelegate processWork:]):
+ (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]):
+ (-[FrameLoadDelegate webView:didStartProvisionalLoadForFrame:]):
+ (-[FrameLoadDelegate webView:didCommitLoadForFrame:]):
+ (-[FrameLoadDelegate webView:didFailProvisionalLoadWithError:forFrame:]):
+ (-[FrameLoadDelegate webView:didFinishLoadForFrame:]):
+ (-[FrameLoadDelegate webView:didFailLoadWithError:forFrame:]):
+ (-[FrameLoadDelegate webView:windowScriptObjectAvailable:]):
+ (-[FrameLoadDelegate webView:didClearWindowObject:forFrame:]):
+ (-[FrameLoadDelegate webView:didReceiveTitle:forFrame:]):
+ (-[FrameLoadDelegate webView:didReceiveServerRedirectForProvisionalLoadForFrame:]):
+ (-[FrameLoadDelegate webView:didReceiveIcon:forFrame:]):
+ (-[FrameLoadDelegate webView:didChangeLocationWithinPageForFrame:]):
+ (-[FrameLoadDelegate webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:]):
+ (-[FrameLoadDelegate webView:didCancelClientRedirectForFrame:]):
+ (-[FrameLoadDelegate webView:willCloseFrame:]):
+ (-[FrameLoadDelegate webView:didFirstLayoutInFrame:]):
+ (-[FrameLoadDelegate webView:didFinishDocumentLoadForFrame:]):
+ (-[FrameLoadDelegate webView:didHandleOnloadEventsForFrame:]):
+ * DumpRenderTree/ResourceLoadDelegate.m:
+ (-[NSURL _drt_descriptionSuitableForTestResult]):
+ * DumpRenderTree/UIDelegate.m:
+ (-[UIDelegate webViewFocus:]):
+
2007-05-16 Kevin McCullough <kmccullough@apple.com>
Reviewed by Darin and Geoff.
*/
@class DumpRenderTreeDraggingInfo;
+@class NavigationController;
@class WebFrame;
+@class WebScriptObject;
@class WebView;
extern BOOL windowIsKey;
-extern WebFrame *frame;
+extern WebFrame *mainFrame;
extern DumpRenderTreeDraggingInfo *draggingInfo;
extern volatile BOOL done;
extern BOOL shouldDumpResourceLoadCallbacks;
+extern BOOL shouldDumpFrameLoadCallbacks;
+extern BOOL dumpTitleChanges;
extern NSMutableSet *disallowedURLs;
extern BOOL waitToDump;
extern BOOL canOpenWindows;
extern BOOL closeWebViews;
extern BOOL addFileToPasteboardOnDrag;
+extern NSMutableArray *workQueue;
+extern WebFrame *topLoadingFrame;
+extern BOOL workQueueFrozen;
+extern NavigationController *navigationController;
WebView *createWebView();
+void dump(void);
+
+@interface LayoutTestController : NSObject
+{
+ WebScriptObject *storedWebScriptObject;
+}
+- (void)dealloc;
+@end
+
#import "DumpRenderTree.h"
-#import "AppleScriptController.h"
#import "EditingDelegate.h"
#import "EventSendingController.h"
-#import "GCController.h"
+#import "FrameLoadDelegate.h"
#import "NavigationController.h"
#import "ObjCPlugin.h"
#import "ObjCPluginFunction.h"
#import "ResourceLoadDelegate.h"
-#import "TextInputController.h"
#import "UIDelegate.h"
#import <ApplicationServices/ApplicationServices.h> // for CMSetDefaultProfileBySpace
#import <CoreFoundation/CoreFoundation.h>
@interface DumpRenderTreeEvent : NSEvent
@end
-@interface WaitUntilDoneDelegate : NSObject
-@end
-
-@interface LayoutTestController : NSObject
-{
- WebScriptObject *storedWebScriptObject;
-}
-- (void)dealloc;
-@end
-
@interface LocalPasteboard : NSPasteboard
{
NSMutableArray *typesArray;
@end
BOOL windowIsKey = YES;
-WebFrame *frame = 0;
+WebFrame *mainFrame = 0;
BOOL shouldDumpEditingCallbacks;
BOOL shouldDumpResourceLoadCallbacks;
+BOOL shouldDumpFrameLoadCallbacks;
NSMutableSet *disallowedURLs = 0;
BOOL waitToDump; // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
BOOL canOpenWindows;
static void displayWebView();
volatile BOOL done;
-static NavigationController *navigationController;
+NavigationController *navigationController = nil;
// Delegates
-static WaitUntilDoneDelegate *waitUntilDoneDelegate;
+static FrameLoadDelegate *frameLoadDelegate;
static UIDelegate *uiDelegate;
static EditingDelegate *editingDelegate;
static ResourceLoadDelegate *resourceLoadDelegate;
// in progress. Usually this is the same as the main frame, but not always. In the case
// where a frameset is loaded, and then new content is loaded into one of the child frames,
// that child frame is the "topmost frame that is loading".
-static WebFrame *topLoadingFrame; // !nil iff a load is in progress
+WebFrame *topLoadingFrame = nil; // !nil iff a load is in progress
static BOOL dumpAsText;
static BOOL dumpDOMAsWebArchive;
static BOOL dumpSourceAsWebArchive;
static BOOL dumpSelectionRect;
-static BOOL dumpTitleChanges;
+BOOL dumpTitleChanges = NO;
static BOOL dumpBackForwardList;
static BOOL dumpChildFrameScrollPositions;
static int dumpPixels;
static unsigned char* screenCaptureBuffer;
static CGColorSpaceRef sharedColorSpace;
// a queue of NSInvocations, queued by callouts from the test, to be exec'ed when the load is done
-static NSMutableArray *workQueue = nil;
+NSMutableArray *workQueue = nil;
// to prevent infinite loops, only the first page of a test can add to a work queue
// (since we may well come back to that same page)
-static BOOL workQueueFrozen;
+BOOL workQueueFrozen = nil;
const unsigned maxViewHeight = 600;
const unsigned maxViewWidth = 800;
WebView *webView = [[WebView alloc] initWithFrame:rect];
[webView setUIDelegate:uiDelegate];
- [webView setFrameLoadDelegate:waitUntilDoneDelegate];
+ [webView setFrameLoadDelegate:frameLoadDelegate];
[webView setEditingDelegate:editingDelegate];
[webView setResourceLoadDelegate:resourceLoadDelegate];
localPasteboards = [[NSMutableDictionary alloc] init];
navigationController = [[NavigationController alloc] init];
- waitUntilDoneDelegate = [[WaitUntilDoneDelegate alloc] init];
+ frameLoadDelegate = [[FrameLoadDelegate alloc] init];
uiDelegate = [[UIDelegate alloc] init];
editingDelegate = [[EditingDelegate alloc] init];
resourceLoadDelegate = [[ResourceLoadDelegate alloc] init];
[[WebPluginDatabase sharedDatabase] refresh];
WebView *webView = createWebView();
- frame = [webView mainFrame];
+ mainFrame = [webView mainFrame];
NSWindow *window = [webView window];
workQueue = [[NSMutableArray alloc] init];
[WebCoreStatistics emptyCache]; // Otherwise SVGImages trigger false positives for Frame/Node counts
[webView close];
- frame = nil;
+ mainFrame = nil;
// Work around problem where registering drag types leaves an outstanding
// "perform selector" on the window, which retains the window. It's a bit
[window close]; // releases when closed
[webView release];
- [waitUntilDoneDelegate release];
+ [frameLoadDelegate release];
[editingDelegate release];
[resourceLoadDelegate release];
[uiDelegate release];
printf("===============================================\n");
}
-static void dump(void)
+void dump(void)
{
if (dumpTree) {
NSString *result = nil;
- dumpAsText |= [[[[frame dataSource] response] MIMEType] isEqualToString:@"text/plain"];
+ dumpAsText |= [[[[mainFrame dataSource] response] MIMEType] isEqualToString:@"text/plain"];
if (dumpAsText) {
- DOMElement *documentElement = [[frame DOMDocument] documentElement];
+ DOMElement *documentElement = [[mainFrame DOMDocument] documentElement];
result = [[(DOMElement *)documentElement innerText] stringByAppendingString:@"\n"];
} else if (dumpDOMAsWebArchive) {
- WebArchive *webArchive = [[frame DOMDocument] webArchive];
+ WebArchive *webArchive = [[mainFrame DOMDocument] webArchive];
result = serializeWebArchiveToXML(webArchive);
} else if (dumpSourceAsWebArchive) {
- WebArchive *webArchive = [[frame dataSource] webArchive];
+ WebArchive *webArchive = [[mainFrame dataSource] webArchive];
result = serializeWebArchiveToXML(webArchive);
} else {
bool isSVGW3CTest = ([currentTest rangeOfString:@"svg/W3C-SVG-1.1"].length);
if (isSVGW3CTest)
- [[frame webView] setFrameSize:NSMakeSize(480, 360)];
+ [[mainFrame webView] setFrameSize:NSMakeSize(480, 360)];
else
- [[frame webView] setFrameSize:NSMakeSize(maxViewWidth, maxViewHeight)];
- result = [frame renderTreeAsExternalRepresentation];
+ [[mainFrame webView] setFrameSize:NSMakeSize(maxViewWidth, maxViewHeight)];
+ result = [mainFrame renderTreeAsExternalRepresentation];
}
if (!result) {
if (dumpAsText)
errorMessage = "[documentElement innerText]";
else if (dumpDOMAsWebArchive)
- errorMessage = "[[frame DOMDocument] webArchive]";
+ errorMessage = "[[mainFrame DOMDocument] webArchive]";
else if (dumpSourceAsWebArchive)
- errorMessage = "[[frame dataSource] webArchive]";
+ errorMessage = "[[mainFrame dataSource] webArchive]";
else
- errorMessage = "[frame renderTreeAsExternalRepresentation]";
+ errorMessage = "[mainFrame renderTreeAsExternalRepresentation]";
printf("ERROR: nil result from %s", errorMessage);
} else {
fputs([result UTF8String], stdout);
if (!dumpAsText && !dumpDOMAsWebArchive && !dumpSourceAsWebArchive)
- dumpFrameScrollPosition(frame);
+ dumpFrameScrollPosition(mainFrame);
}
if (dumpBackForwardList) {
if (dumpPixels) {
if (!dumpAsText && !dumpDOMAsWebArchive && !dumpSourceAsWebArchive) {
// grab a bitmap from the view
- WebView* view = [frame webView];
+ WebView* view = [mainFrame webView];
NSSize webViewSize = [view frame].size;
CGContextRef cgContext = CGBitmapContextCreate(screenCaptureBuffer, webViewSize.width, webViewSize.height, 8, webViewSize.width * 4, sharedColorSpace, kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedLast);
}
}
if (dumpSelectionRect) {
- NSView *documentView = [[frame frameView] documentView];
+ NSView *documentView = [[mainFrame frameView] documentView];
if ([documentView conformsToProtocol:@protocol(WebDocumentSelection)]) {
[[NSColor redColor] set];
[NSBezierPath strokeRect:[documentView convertRect:[(id <WebDocumentSelection>)documentView selectionRect] fromView:nil]];
done = YES;
}
-@implementation WaitUntilDoneDelegate
-
-// Exec messages in the work queue until they're all done, or one of them starts a new load
-- (void)processWork:(id)dummy
-{
- // quit doing work once a load is in progress
- while ([workQueue count] > 0 && !topLoadingFrame) {
- [[workQueue objectAtIndex:0] invoke];
- [workQueue removeObjectAtIndex:0];
- }
-
- // if we didn't start a new load, then we finished all the commands, so we're ready to dump state
- if (!topLoadingFrame && !waitToDump)
- dump();
-}
-
-- (void)webView:(WebView *)c locationChangeDone:(NSError *)error forDataSource:(WebDataSource *)dataSource
-{
- if ([dataSource webFrame] == topLoadingFrame) {
- topLoadingFrame = nil;
- workQueueFrozen = YES; // first complete load freezes the queue for the rest of this test
- if (!waitToDump) {
- if ([workQueue count] > 0)
- [self performSelector:@selector(processWork:) withObject:nil afterDelay:0];
- else
- dump();
- }
- }
-}
-
-- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)f
-{
- ASSERT([f provisionalDataSource]);
- // Make sure we only set this once per test. If it gets cleared, and then set again, we might
- // end up doing two dumps for one test.
- if (!topLoadingFrame && !done)
- topLoadingFrame = f;
-}
-
-- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)f
-{
- ASSERT(![f provisionalDataSource]);
- ASSERT([f dataSource]);
-
- windowIsKey = YES;
- NSView *documentView = [[frame frameView] documentView];
- [[[frame webView] window] makeFirstResponder:documentView];
- if ([documentView isKindOfClass:[WebHTMLView class]])
- [(WebHTMLView *)documentView _updateActiveState];
-}
-
-- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
-{
- ASSERT([frame provisionalDataSource]);
-
- [self webView:sender locationChangeDone:error forDataSource:[frame provisionalDataSource]];
-}
-
-- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
-{
- // FIXME: This call to displayIfNeeded can be removed when <rdar://problem/5092361> is fixed.
- // After that is fixed, we will reenable painting after WebCore is done loading the document,
- // and this call will no longer be needed.
- if ([[sender mainFrame] isEqual:frame])
- [sender displayIfNeeded];
- [self webView:sender locationChangeDone:nil forDataSource:[frame dataSource]];
- [navigationController webView:sender didFinishLoadForFrame:frame];
-}
-
-- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
-{
- ASSERT(![frame provisionalDataSource]);
- ASSERT([frame dataSource]);
-
- [self webView:sender locationChangeDone:error forDataSource:[frame dataSource]];
-}
-
-- (void)webView:(WebView *)sender windowScriptObjectAvailable:(WebScriptObject *)obj
-{
- ASSERT_NOT_REACHED();
-}
-
-- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)obj forFrame:(WebFrame *)frame
-{
- ASSERT(obj == [frame windowObject]);
- ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
-
- LayoutTestController *ltc = [[LayoutTestController alloc] init];
- [obj setValue:ltc forKey:@"layoutTestController"];
- [ltc release];
-
- EventSendingController *esc = [[EventSendingController alloc] init];
- [obj setValue:esc forKey:@"eventSender"];
- [esc release];
-
- TextInputController *tic = [[TextInputController alloc] initWithWebView:sender];
- [obj setValue:tic forKey:@"textInputController"];
- [tic release];
-
- AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
- [obj setValue:asc forKey:@"appleScriptController"];
- [asc release];
-
- GCController *gcc = [[GCController alloc] init];
- [obj setValue:gcc forKey:@"GCController"];
- [gcc release];
-
- [obj setValue:navigationController forKey:@"navigationController"];
-
- ObjCPlugin *plugin = [[ObjCPlugin alloc] init];
- [obj setValue:plugin forKey:@"objCPlugin"];
- [plugin release];
-
- ObjCPluginFunction *pluginFunction = [[ObjCPluginFunction alloc] init];
- [obj setValue:pluginFunction forKey:@"objCPluginFunction"];
- [pluginFunction release];
-}
-
-- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
-{
- if (dumpTitleChanges)
- printf("TITLE CHANGED: %s\n", [title UTF8String]);
-}
-
-@end
-
@implementation LayoutTestController
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
|| aSelector == @selector(dumpChildFrameScrollPositions)
|| aSelector == @selector(dumpEditingCallbacks)
|| aSelector == @selector(dumpResourceLoadCallbacks)
+ || aSelector == @selector(dumpFrameLoadCallbacks)
|| aSelector == @selector(setWindowIsKey:)
|| aSelector == @selector(setMainFrameIsFirstResponder:)
|| aSelector == @selector(dumpSelectionRect)
- (void)clearBackForwardList
{
- WebBackForwardList *backForwardList = [[frame webView] backForwardList];
+ WebBackForwardList *backForwardList = [[mainFrame webView] backForwardList];
WebHistoryItem *item = [[backForwardList currentItem] retain];
// We clear the history by setting the back/forward list's capacity to 0
- (void)setUseDashboardCompatibilityMode:(BOOL)flag
{
- [[frame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:flag];
+ [[mainFrame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:flag];
}
- (void)setCloseRemainingWindowsWhenComplete:(BOOL)closeWindows
shouldDumpResourceLoadCallbacks = YES;
}
+- (void)dumpFrameLoadCallbacks
+{
+ shouldDumpFrameLoadCallbacks = YES;
+}
+
- (void)setWindowIsKey:(BOOL)flag
{
windowIsKey = flag;
- NSView *documentView = [[frame frameView] documentView];
+ NSView *documentView = [[mainFrame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView *)documentView _updateActiveState];
}
- (void)setMainFrameIsFirstResponder:(BOOL)flag
{
- NSView *documentView = [[frame frameView] documentView];
+ NSView *documentView = [[mainFrame frameView] documentView];
NSResponder *firstResponder = flag ? documentView : nil;
- [[[frame webView] window] makeFirstResponder:firstResponder];
+ [[[mainFrame webView] window] makeFirstResponder:firstResponder];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView *)documentView _updateActiveState];
{
WebFrame *targetFrame;
if (target && ![target isKindOfClass:[WebUndefined class]])
- targetFrame = [frame findFrameNamed:target];
+ targetFrame = [mainFrame findFrameNamed:target];
else
- targetFrame = frame;
+ targetFrame = mainFrame;
[targetFrame loadRequest:[NSURLRequest requestWithURL:url]];
}
{
int bfIndex = [index intValue];
if (bfIndex == 1)
- [[frame webView] goForward];
+ [[mainFrame webView] goForward];
if (bfIndex == -1)
- [[frame webView] goBack];
+ [[mainFrame webView] goBack];
else {
- WebBackForwardList *bfList = [[frame webView] backForwardList];
- [[frame webView] goToBackForwardItem:[bfList itemAtIndex:bfIndex]];
+ WebBackForwardList *bfList = [[mainFrame webView] backForwardList];
+ [[mainFrame webView] goToBackForwardItem:[bfList itemAtIndex:bfIndex]];
}
}
- (void)queueReload
{
- [self _addWorkForTarget:[frame webView] selector:@selector(reload:) arg1:self arg2:nil];
+ [self _addWorkForTarget:[mainFrame webView] selector:@selector(reload:) arg1:self arg2:nil];
}
- (void)queueScript:(NSString *)script
{
- [self _addWorkForTarget:[frame webView] selector:@selector(stringByEvaluatingJavaScriptFromString:) arg1:script arg2:nil];
+ [self _addWorkForTarget:[mainFrame webView] selector:@selector(stringByEvaluatingJavaScriptFromString:) arg1:script arg2:nil];
}
- (void)queueLoad:(NSString *)URLString target:(NSString *)target
{
- NSURL *URL = [NSURL URLWithString:URLString relativeToURL:[[[frame dataSource] response] URL]];
+ NSURL *URL = [NSURL URLWithString:URLString relativeToURL:[[[mainFrame dataSource] response] URL]];
[self _addWorkForTarget:self selector:@selector(_doLoad:target:) arg1:URL arg2:target];
}
- (void)setAcceptsEditing:(BOOL)newAcceptsEditing
{
- [(EditingDelegate *)[[frame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing];
+ [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing];
}
- (void)setTabKeyCyclesThroughElements:(BOOL)newTabKeyCyclesThroughElements
{
- [[frame webView] setTabKeyCyclesThroughElements:newTabKeyCyclesThroughElements];
+ [[mainFrame webView] setTabKeyCyclesThroughElements:newTabKeyCyclesThroughElements];
}
- (void)storeWebScriptObject:(WebScriptObject *)webScriptObject
@end
+static bool shouldLogFrameLoadDelegates(const char *pathOrURL)
+{
+ return strstr(pathOrURL, "loading/");
+}
+
static void runTest(const char *pathOrURL)
{
CFStringRef pathOrURLString = CFStringCreateWithCString(NULL, pathOrURL, kCFStringEncodingUTF8);
return;
}
- [(EditingDelegate *)[[frame webView] editingDelegate] setAcceptsEditing:YES];
- [[frame webView] setTabKeyCyclesThroughElements: YES];
+ [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:YES];
+ [[mainFrame webView] setTabKeyCyclesThroughElements: YES];
done = NO;
topLoadingFrame = nil;
waitToDump = NO;
dumpChildFrameScrollPositions = NO;
shouldDumpEditingCallbacks = NO;
shouldDumpResourceLoadCallbacks = NO;
+ shouldDumpFrameLoadCallbacks = NO;
dumpSelectionRect = NO;
dumpTitleChanges = NO;
dumpBackForwardList = NO;
canOpenWindows = NO;
closeWebViews = YES;
addFileToPasteboardOnDrag = NO;
- [[frame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:NO];
+ [[mainFrame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:NO];
testRepaint = testRepaintDefault;
repaintSweepHorizontally = repaintSweepHorizontallyDefault;
if ([WebHistory optionalSharedHistory])
CFRelease(currentTest);
currentTest = (NSString *)pathOrURLString;
[prevTestBFItem release];
- prevTestBFItem = [[[[frame webView] backForwardList] currentItem] retain];
+ prevTestBFItem = [[[[mainFrame webView] backForwardList] currentItem] retain];
[workQueue removeAllObjects];
workQueueFrozen = NO;
[WebCoreStatistics startIgnoringWebCoreNodeLeaks];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [frame loadRequest:[NSURLRequest requestWithURL:(NSURL *)URL]];
+ if (shouldLogFrameLoadDelegates(pathOrURL))
+ shouldDumpFrameLoadCallbacks = YES;
+ [mainFrame loadRequest:[NSURLRequest requestWithURL:(NSURL *)URL]];
CFRelease(URL);
[pool release];
while (!done) {
}
pool = [[NSAutoreleasePool alloc] init];
[EventSendingController clearSavedEvents];
- [[frame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
+ [[mainFrame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
if (closeRemainingWindowsWhenComplete) {
NSArray* array = [(NSArray *)allWindowsRef copy];
NSWindow *window = [array objectAtIndex:i];
// Don't try to close the main window
- if (window == [[frame webView] window])
+ if (window == [[mainFrame webView] window])
continue;
WebView *webView = [[[window contentView] subviews] objectAtIndex:0];
[pool release];
// We should only have our main window left when we're done
- assert(CFArrayGetCount(allWindowsRef) == 1);
- assert(CFArrayGetValueAtIndex(allWindowsRef, 0) == [[frame webView] window]);
+ ASSERT(CFArrayGetCount(allWindowsRef) == 1);
+ ASSERT(CFArrayGetValueAtIndex(allWindowsRef, 0) == [[mainFrame webView] window]);
if (_shouldIgnoreWebCoreNodeLeaks)
[WebCoreStatistics stopIgnoringWebCoreNodeLeaks];
static void displayWebView()
{
- NSView *webView = [frame webView];
+ NSView *webView = [mainFrame webView];
[webView display];
[webView lockFocus];
[[[NSColor blackColor] colorWithAlphaComponent:0.66] set];
+ (NSPoint)mouseLocation
{
- return [[[frame webView] window] convertBaseToScreen:lastMousePosition];
+ return [[[mainFrame webView] window] convertBaseToScreen:lastMousePosition];
}
@end
22181BD209DC8C4B008342E8 /* ObjCPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 22181BCE09DC8C4B008342E8 /* ObjCPlugin.m */; };
22181BD309DC8C4B008342E8 /* ObjCPluginFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 22181BCF09DC8C4B008342E8 /* ObjCPluginFunction.h */; };
22181BD409DC8C4B008342E8 /* ObjCPluginFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = 22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */; };
+ 6508A2980BFABB8000AD2696 /* FrameLoadDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */; };
+ 6508A2990BFABB8100AD2696 /* FrameLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */; };
+ 6508A29A0BFABB8200AD2696 /* ResourceLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6CA8630B7120CF00A24B62 /* ResourceLoadDelegate.h */; };
9340994C08540CAE007F3BC8 /* DumpRenderTreePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */; };
9340994E08540CAE007F3BC8 /* DumpRenderTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* DumpRenderTree.m */; settings = {ATTRIBUTES = (); COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
9340995108540CAE007F3BC8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9335435F03D75502008635CE /* WebKit.framework */; };
22181BCF09DC8C4B008342E8 /* ObjCPluginFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ObjCPluginFunction.h; sourceTree = "<group>"; };
22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ObjCPluginFunction.m; sourceTree = "<group>"; };
32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
+ 6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadDelegate.h; sourceTree = "<group>"; };
+ 6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FrameLoadDelegate.m; sourceTree = "<group>"; };
9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
93442CF408F8BA4900BFE8CA /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
1422A2750AF6F4BD00E1A883 /* Delegates */ = {
isa = PBXGroup;
children = (
+ 6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */,
+ 6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */,
A803FFF309CAAFE0009B2A37 /* EditingDelegate.h */,
A803FFF409CAAFE0009B2A37 /* EditingDelegate.m */,
1A6CA8630B7120CF00A24B62 /* ResourceLoadDelegate.h */,
22181BD309DC8C4B008342E8 /* ObjCPluginFunction.h in Headers */,
14770FE20A22ADF7009342EE /* GCController.h in Headers */,
1422A1BA0AF6EDD600E1A883 /* UIDelegate.h in Headers */,
+ 6508A2990BFABB8100AD2696 /* FrameLoadDelegate.h in Headers */,
+ 6508A29A0BFABB8200AD2696 /* ResourceLoadDelegate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
14770FE30A22ADF7009342EE /* GCController.mm in Sources */,
1A6CA8DE0B7122D100A24B62 /* ResourceLoadDelegate.m in Sources */,
1422A1BB0AF6EDD600E1A883 /* UIDelegate.m in Sources */,
+ 6508A2980BFABB8000AD2696 /* FrameLoadDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
- (NSWindow *)draggingDestinationWindow
{
- return [[frame webView] window];
+ return [[mainFrame webView] window];
}
- (NSDragOperation)draggingSourceOperationMask
- (void)mouseDown
{
- [[[frame frameView] documentView] layout];
+ [[[mainFrame frameView] documentView] layout];
if ([self currentEventTime] - lastClick >= 1)
clickCount = 1;
else
location:lastMousePosition
modifierFlags:0
timestamp:[self currentEventTime]
- windowNumber:[[[frame webView] window] windowNumber]
+ windowNumber:[[[mainFrame webView] window] windowNumber]
context:[NSGraphicsContext currentContext]
eventNumber:++eventNumber
clickCount:clickCount
pressure:0.0];
- NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+ NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
if (subView) {
[subView mouseDown:event];
down = YES;
return;
}
- [[[frame frameView] documentView] layout];
+ [[[mainFrame frameView] documentView] layout];
NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseUp
location:lastMousePosition
modifierFlags:0
timestamp:[self currentEventTime]
- windowNumber:[[[frame webView] window] windowNumber]
+ windowNumber:[[[mainFrame webView] window] windowNumber]
context:[NSGraphicsContext currentContext]
eventNumber:++eventNumber
clickCount:clickCount
pressure:0.0];
- NSView *targetView = [[frame webView] hitTest:[event locationInWindow]];
+ NSView *targetView = [[mainFrame webView] hitTest:[event locationInWindow]];
// FIXME: Silly hack to teach DRT to respect capturing mouse events outside the WebView.
// The right solution is just to use NSApplication's built-in event sending methods,
// instead of rolling our own algorithm for selecting an event target.
- targetView = targetView ? targetView : [[frame frameView] documentView];
+ targetView = targetView ? targetView : [[mainFrame frameView] documentView];
assert(targetView);
[targetView mouseUp:event];
down = NO;
lastClick = [event timestamp];
if (draggingInfo) {
- WebView *webView = [frame webView];
+ WebView *webView = [mainFrame webView];
NSDragOperation dragOperation = [webView draggingUpdated:draggingInfo];
return;
}
- NSView *view = [frame webView];
+ NSView *view = [mainFrame webView];
lastMousePosition = [view convertPoint:NSMakePoint(x, [view frame].size.height - y) toView:nil];
NSEvent *event = [NSEvent mouseEventWithType:(down ? NSLeftMouseDragged : NSMouseMoved)
location:lastMousePosition
clickCount:(down ? clickCount : 0)
pressure:0.0];
- NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+ NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
if (subView) {
if (down) {
[subView mouseDragged:event];
if (draggingInfo) {
[[draggingInfo draggingSource] draggedImage:[draggingInfo draggedImage] movedTo:lastMousePosition];
- [[frame webView] draggingUpdated:draggingInfo];
+ [[mainFrame webView] draggingUpdated:draggingInfo];
}
} else
[subView mouseMoved:event];
- (void)contextClick
{
- [[[frame frameView] documentView] layout];
+ [[[mainFrame frameView] documentView] layout];
if ([self currentEventTime] - lastClick >= 1)
clickCount = 1;
else
location:lastMousePosition
modifierFlags:0
timestamp:[self currentEventTime]
- windowNumber:[[[frame webView] window] windowNumber]
+ windowNumber:[[[mainFrame webView] window] windowNumber]
context:[NSGraphicsContext currentContext]
eventNumber:++eventNumber
clickCount:clickCount
pressure:0.0];
- NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+ NSView *subView = [[mainFrame webView] hitTest:[event locationInWindow]];
if (subView)
[subView menuForEvent:event];
}
break;
}
- [[[frame frameView] documentView] layout];
+ [[[mainFrame frameView] documentView] layout];
NSEvent *event = [NSEvent keyEventWithType:NSKeyDown
location:NSMakePoint(5, 5)
modifierFlags:mask
timestamp:[self currentEventTime]
- windowNumber:[[[frame webView] window] windowNumber]
+ windowNumber:[[[mainFrame webView] window] windowNumber]
context:[NSGraphicsContext currentContext]
characters:character
charactersIgnoringModifiers:character
keyCode:0];
- NSResponder *firstResponder = [[[frame webView] window] firstResponder];
+ NSResponder *firstResponder = [[[mainFrame webView] window] firstResponder];
[firstResponder keyDown:event];
}
--- /dev/null
+/*
+ * Copyright (C) 2007, 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface FrameLoadDelegate : NSObject {
+}
+
+@end
--- /dev/null
+/*
+ * Copyright (C) 2007, 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
+ */
+
+#import "FrameLoadDelegate.h"
+
+#import "AppleScriptController.h"
+#import "DumpRenderTree.h"
+#import "EventSendingController.h"
+#import "GCController.h"
+#import "NavigationController.h"
+#import "ObjCPlugin.h"
+#import "ObjCPluginFunction.h"
+
+#import "TextInputController.h"
+
+#import <JavaScriptCore/Assertions.h>
+#import <JavaScriptCore/JavaScriptCore.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/WebHTMLViewPrivate.h>
+#import <WebKit/WebFramePrivate.h>
+#import <WebCore/WebScriptObjectPendingPublic.h>
+
+@interface NSURL (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@interface NSError (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@interface NSURLResponse (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@interface NSURLRequest (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@interface WebFrame (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@implementation WebFrame (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult
+{
+ BOOL isMainFrame = (self == [[self webView] mainFrame]);
+ NSString *name = [self name];
+ if (isMainFrame) {
+ if ([name length])
+ return [NSString stringWithFormat:@"main frame \"%@\"", name];
+ else
+ return @"main frame";
+ } else {
+ if (name)
+ return [NSString stringWithFormat:@"frame \"%@\"", name];
+ else
+ return @"frame (anonymous)";
+ }
+}
+@end
+
+@implementation FrameLoadDelegate
+
+// Exec messages in the work queue until they're all done, or one of them starts a new load
+- (void)processWork:(id)dummy
+{
+ // quit doing work once a load is in progress
+ while ([workQueue count] > 0 && !topLoadingFrame) {
+ [[workQueue objectAtIndex:0] invoke];
+ [workQueue removeObjectAtIndex:0];
+ }
+
+ // if we didn't start a new load, then we finished all the commands, so we're ready to dump state
+ if (!topLoadingFrame && !waitToDump)
+ dump();
+}
+
+- (void)webView:(WebView *)c locationChangeDone:(NSError *)error forDataSource:(WebDataSource *)dataSource
+{
+ if ([dataSource webFrame] == topLoadingFrame) {
+ topLoadingFrame = nil;
+ workQueueFrozen = YES; // first complete load freezes the queue for the rest of this test
+ if (!waitToDump) {
+ if ([workQueue count] > 0)
+ [self performSelector:@selector(processWork:) withObject:nil afterDelay:0];
+ else
+ dump();
+ }
+ }
+}
+
+- (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didStartProvisionalLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT([frame provisionalDataSource]);
+ // Make sure we only set this once per test. If it gets cleared, and then set again, we might
+ // end up doing two dumps for one test.
+ if (!topLoadingFrame && !done)
+ topLoadingFrame = frame;
+}
+
+- (void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didCommitLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT(![frame provisionalDataSource]);
+ ASSERT([frame dataSource]);
+
+ windowIsKey = YES;
+ NSView *documentView = [[mainFrame frameView] documentView];
+ [[[mainFrame webView] window] makeFirstResponder:documentView];
+ if ([documentView isKindOfClass:[WebHTMLView class]])
+ [(WebHTMLView *)documentView _updateActiveState];
+}
+
+- (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didFailProvisionalLoadWithError", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT([frame provisionalDataSource]);
+ [self webView:sender locationChangeDone:error forDataSource:[frame provisionalDataSource]];
+}
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didFinishLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ // FIXME: This call to displayIfNeeded can be removed when <rdar://problem/5092361> is fixed.
+ // After that is fixed, we will reenable painting after WebCore is done loading the document,
+ // and this call will no longer be needed.
+ if ([[sender mainFrame] isEqual:frame])
+ [sender displayIfNeeded];
+ [self webView:sender locationChangeDone:nil forDataSource:[frame dataSource]];
+ [navigationController webView:sender didFinishLoadForFrame:frame];
+}
+
+- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didFailLoadWithError", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT(![frame provisionalDataSource]);
+ ASSERT([frame dataSource]);
+
+ [self webView:sender locationChangeDone:error forDataSource:[frame dataSource]];
+}
+
+- (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"?? - windowScriptObjectAvailable"];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)obj forFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didClearWindowObjectForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ ASSERT(obj == [frame windowObject]);
+ ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
+
+ LayoutTestController *ltc = [[LayoutTestController alloc] init];
+ [obj setValue:ltc forKey:@"layoutTestController"];
+ [ltc release];
+
+ EventSendingController *esc = [[EventSendingController alloc] init];
+ [obj setValue:esc forKey:@"eventSender"];
+ [esc release];
+
+ TextInputController *tic = [[TextInputController alloc] initWithWebView:sender];
+ [obj setValue:tic forKey:@"textInputController"];
+ [tic release];
+
+ AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
+ [obj setValue:asc forKey:@"appleScriptController"];
+ [asc release];
+
+ GCController *gcc = [[GCController alloc] init];
+ [obj setValue:gcc forKey:@"GCController"];
+ [gcc release];
+
+ [obj setValue:navigationController forKey:@"navigationController"];
+
+ ObjCPlugin *plugin = [[ObjCPlugin alloc] init];
+ [obj setValue:plugin forKey:@"objCPlugin"];
+ [plugin release];
+
+ ObjCPluginFunction *pluginFunction = [[ObjCPluginFunction alloc] init];
+ [obj setValue:pluginFunction forKey:@"objCPluginFunction"];
+ [pluginFunction release];
+}
+
+- (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didReceiveTitle: %@", [frame _drt_descriptionSuitableForTestResult], title];
+ printf ("%s\n", [string UTF8String]);
+ }
+
+ if (dumpTitleChanges)
+ printf("TITLE CHANGED: %s\n", [title UTF8String]);
+}
+
+- (void)webView:(WebView *)sender didReceiveServerRedirectForProvisionalLoadForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didReceiveServerRedirectForProvisionalLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didReceiveIconForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didChangeLocationWithinPageForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didChangeLocationWithinPageForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date forFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - willPerformClientRedirectToURL: %@ ", [frame _drt_descriptionSuitableForTestResult], [URL _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didCancelClientRedirectForFrame:(WebFrame *)frame
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didCancelClientRedirectForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender willCloseFrame:(WebFrame *)frame;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - willCloseFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didFirstLayoutInFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didFinishDocumentLoadForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+- (void)webView:(WebView *)sender didHandleOnloadEventsForFrame:(WebFrame *)frame;
+{
+ if (shouldDumpFrameLoadCallbacks && !done) {
+ NSString *string = [NSString stringWithFormat:@"%@ - didHandleOnloadEventsForFrame", [frame _drt_descriptionSuitableForTestResult]];
+ printf ("%s\n", [string UTF8String]);
+ }
+}
+
+@end
if (![self isFileURL])
return [self description];
- WebDataSource *dataSource = [frame dataSource];
+ WebDataSource *dataSource = [mainFrame dataSource];
if (!dataSource)
- dataSource = [frame provisionalDataSource];
+ dataSource = [mainFrame provisionalDataSource];
NSString *basePath = [[[[dataSource request] URL] path] stringByDeletingLastPathComponent];
- (void)webViewFocus:(WebView *)webView
{
windowIsKey = YES;
- NSView *documentView = [[frame frameView] documentView];
+ NSView *documentView = [[mainFrame frameView] documentView];
if ([documentView isKindOfClass:[WebHTMLView class]])
[(WebHTMLView *)documentView _updateActiveState];
}