Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=7223
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2006 17:36:47 +0000 (17:36 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2006 17:36:47 +0000 (17:36 +0000)
        Reproducible crash when tabbing to a frame that has not been loaded
        Also adds support for keyDown() to DumpRenderTree.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/focusingUnloadedFrame-expected.checksum [new file with mode: 0644]
LayoutTests/fast/events/focusingUnloadedFrame-expected.png [new file with mode: 0644]
LayoutTests/fast/events/focusingUnloadedFrame-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/focusingUnloadedFrame.html [new file with mode: 0644]
LayoutTests/fast/events/resources/frontpage.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.m
WebKitTools/DumpRenderTree/EventSendingController.m

index 43d0104..4a3de49 100644 (file)
@@ -1,3 +1,15 @@
+2006-03-21  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej
+
+        Layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7223
+
+        * fast/events/focusingUnloadedFrame-expected.checksum: Added.
+        * fast/events/focusingUnloadedFrame-expected.png: Added.
+        * fast/events/focusingUnloadedFrame-expected.txt: Added.
+        * fast/events/focusingUnloadedFrame.html: Added.
+        * fast/events/resources/frontpage.html: Added.
+
 2006-03-21  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by andersca.
diff --git a/LayoutTests/fast/events/focusingUnloadedFrame-expected.checksum b/LayoutTests/fast/events/focusingUnloadedFrame-expected.checksum
new file mode 100644 (file)
index 0000000..1c571fc
--- /dev/null
@@ -0,0 +1 @@
+0e5c69736066f2e56bd564933f9a644c
\ No newline at end of file
diff --git a/LayoutTests/fast/events/focusingUnloadedFrame-expected.png b/LayoutTests/fast/events/focusingUnloadedFrame-expected.png
new file mode 100644 (file)
index 0000000..d8d0099
Binary files /dev/null and b/LayoutTests/fast/events/focusingUnloadedFrame-expected.png differ
diff --git a/LayoutTests/fast/events/focusingUnloadedFrame-expected.txt b/LayoutTests/fast/events/focusingUnloadedFrame-expected.txt
new file mode 100644 (file)
index 0000000..2fe2063
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderFrameSet {FRAMESET} at (0,0) size 800x600
+      RenderFrame {FRAME} at (0,0) size 800x600
+        layer at (0,0) size 798x596
+          RenderCanvas at (0,0) size 798x596
+        layer at (0,0) size 798x596
+          RenderBlock {HTML} at (0,0) size 798x596
+            RenderBody {BODY} at (8,8) size 782x580
+              RenderText {TEXT} at (0,0) size 764x36
+                text run at (0,0) width 654: "To reproduce the original crash outside of DumpRenderTree, press option-tab twice. After focusing the "
+                text run at (654,0) width 110: "link below on the"
+                text run at (0,18) width 512: "first option-tab, the focus loop will try to focus the unloaded frame on the second "
+                text run at (512,18) width 68: "and crash. "
+              RenderInline {A} at (0,0) size 37x18 [color=#0000EE]
+                RenderText {TEXT} at (580,18) size 37x18
+                  text run at (580,18) width 37: "Crash"
+              RenderText {TEXT} at (0,0) size 0x0
+              RenderText {TEXT} at (0,0) size 0x0
+              RenderText {TEXT} at (0,0) size 0x0
+      RenderFrame {FRAME} at (0,0) size 0x0
diff --git a/LayoutTests/fast/events/focusingUnloadedFrame.html b/LayoutTests/fast/events/focusingUnloadedFrame.html
new file mode 100644 (file)
index 0000000..2ba25bd
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
+"http://www.w3.org/TR/html4/frameset.dtd"> 
+<html>
+<head>
+
+
+<script>
+function step2() {
+    var modifiers = ["altKey"];
+    eventSender.keyDown("\t", modifiers);
+    eventSender.keyDown("\t", modifiers);
+    window.layoutTestController.notifyDone();
+}
+
+function foo() {
+    if (!window.layoutTestController)
+        return;
+    
+    window.layoutTestController.waitUntilDone();
+    window.setTimeout('step2()', 900);
+}
+
+
+</script>
+
+</head>
+<body onload="foo()">
+<frameset>
+    <frame src="resources/frontpage.html">  <!-- A page containing a link -->
+    <frame src="resources/notfound.html">        <!-- A page that can't be found -->
+</frameset>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/events/resources/frontpage.html b/LayoutTests/fast/events/resources/frontpage.html
new file mode 100644 (file)
index 0000000..d4fca45
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+  <head>
+  </head>
+  <body>
+     To reproduce the original crash outside of DumpRenderTree, press option-tab twice. After focusing the
+     link below on the first option-tab, the focus loop will try to focus the unloaded frame on the second
+     and crash.
+     <a href="">Crash</a>
+  </body>
+</html>
index 9cb7efa..8a7f1fd 100644 (file)
@@ -1,3 +1,14 @@
+2006-03-21  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej
+
+        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=7223 
+        Reproducible crash when tabbing to a frame that has not been loaded
+
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::nextKeyViewInFrame): When a renderer doesn't 
+        have a widget, skip it in the focus loop.
+
 2006-03-20  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by mjs.
index cbb09b0..9e54d3e 100644 (file)
@@ -879,11 +879,14 @@ NSView *FrameMac::nextKeyViewInFrame(Node *node, KWQSelectionDirection direction
         if (renderer->isWidget()) {
             RenderWidget *renderWidget = static_cast<RenderWidget *>(renderer);
             Widget *widget = renderWidget->widget();
+            if (!widget)
+                continue;
+            
             FrameView *childFrameWidget = widget->isFrameView() ? static_cast<FrameView *>(widget) : 0;
             NSView *view = nil;
             if (childFrameWidget)
                 view = Mac(childFrameWidget->frame())->nextKeyViewInFrame(0, direction);
-            else if (widget)
+            else
                 view = widget->getView();
             if (view)
                 return view;
index bef2780..5ea8f39 100644 (file)
@@ -1,3 +1,16 @@
+2006-03-21  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Maciej
+
+        Add support for keyDown() to DumpRenderTree.
+
+        * DumpRenderTree/DumpRenderTree.m:
+        (main): Set the preference for tabbing to links.
+        * DumpRenderTree/EventSendingController.m:
+        (+[EventSendingController isSelectorExcludedFromWebScript:]):
+        (+[EventSendingController webScriptNameForSelector:]):
+        (-[EventSendingController keyDown:withModifiers:]):
+
 2006-03-20  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by hyatt.
index fab0d92..1bf7da9 100644 (file)
@@ -243,6 +243,8 @@ int main(int argc, const char *argv[])
     [webView setUIDelegate:delegate];
     frame = [webView mainFrame];
     
+    [[webView preferences] setTabsToLinks:YES];
+    
     NSString *pwd = [[NSString stringWithUTF8String:argv[0]] stringByDeletingLastPathComponent];
     [WebPluginDatabase setAdditionalWebPlugInPaths:[NSArray arrayWithObject:pwd]];
     [[WebPluginDatabase installedPlugins] refresh];
index f767062..8f110f5 100644 (file)
@@ -42,7 +42,8 @@ NSPoint lastMousePosition;
             || aSelector == @selector(mouseUp)
             || aSelector == @selector(mouseClick)
             || aSelector == @selector(mouseMoveToX:Y:)
-            || aSelector == @selector(leapForward:))
+            || aSelector == @selector(leapForward:)
+            || aSelector == @selector(keyDown:withModifiers:))
         return NO;
     return YES;
 }
@@ -53,6 +54,8 @@ NSPoint lastMousePosition;
         return @"mouseMoveTo";
     if (aSelector == @selector(leapForward:))
         return @"leapForward";
+    if (aSelector == @selector(keyDown:withModifiers:))
+        return @"keyDown";
     return nil;
 }
 
@@ -191,4 +194,44 @@ NSPoint lastMousePosition;
     }
 }
 
+- (void)keyDown:(NSString *)character withModifiers:(WebScriptObject *)modifiers
+{
+    NSString *modifier = nil;
+    int mask = 0;
+    
+    for (unsigned i = 0; modifiers && [modifiers webScriptValueAtIndex:i]; i++) {
+        modifier = (NSString *)[modifiers webScriptValueAtIndex:i];
+        if ([modifier isEqual:@"ctrlKey"])
+            mask |= NSControlKeyMask;
+        else if ([modifier isEqual:@"shiftKey"])
+            mask |= NSShiftKeyMask;
+        else if ([modifier isEqual:@"altKey"])
+            mask |= NSAlternateKeyMask;
+        else if ([modifier isEqual:@"metaKey"])
+            mask |= NSCommandKeyMask;
+        else
+            break;
+    }
+
+    [[[frame frameView] documentView] layout];
+    
+    NSEvent *event = [NSEvent keyEventWithType:NSKeyDown
+                        location:NSMakePoint(5, 5)
+                        modifierFlags:mask
+                        timestamp:[self currentEventTime]
+                        windowNumber:[[[frame webView] window] windowNumber]
+                        context:[NSGraphicsContext currentContext]
+                        characters:character
+                        charactersIgnoringModifiers:character
+                        isARepeat:NO
+                        keyCode:0];
+    
+
+    NSView *subView = [[frame webView] hitTest:[event locationInWindow]];
+    if (subView) {
+        [subView keyDown:event];
+        down = YES;
+    }
+}
+
 @end