LayoutTests/ChangeLog

 12011-10-03 Jon Lee <jonlee@apple.com>
 2
 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview
 4 https://bugs.webkit.org/show_bug.cgi?id=68412
 5 <rdar://problem/9988252>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 The option-key navigation is only relevant to the Mac platform.
 10
 11 * platform/mac/fast/forms/focus-option-control-on-page-expected.txt: Added.
 12 * platform/mac/fast/forms/focus-option-control-on-page.html: Added.
 13 * platform/mac/fast/forms/script-tests/focus-option-control-on-page.js: Added.
 14 (startTest):
 15 (runKeyPresses):
 16 (notifyDone):
 17 (log):
 18
1192011-10-03 Adam Barth <abarth@webkit.org>
220
321 Delete bogus expected PNG.

LayoutTests/platform/mac/fast/forms/focus-option-control-on-page-expected.txt

 1https://bugs.webkit.org/show_bug.cgi?id=68412 - This test checks to see if option(alt)-tabbing properly focuses form elements that are normally not focused. For testing, the assumption is that by default pressing tab will skip over buttons, and option-tab will include buttons.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6
 7Pressing tab 4 times:
 8PASS result is " /1:focused text field /2: /3:focused text field /4:"
 9Pressing shift-tab 4 times:
 10PASS result is " /1:focused text field /2: /3:focused text field /4:"
 11Pressing option-tab 4 times:
 12PASS result is " /1:focused first button /2:focused text field /3:focused second button /4:"
 13Pressing shift-option-tab 4 times:
 14PASS result is " /1:focused second button /2:focused text field /3:focused first button /4:"
 15

LayoutTests/platform/mac/fast/forms/focus-option-control-on-page.html

 1<!DOCTYPE HTML>
 2<html>
 3<head>
 4<link rel="stylesheet" href="../../../../fast/js/resources/js-test-style.css">
 5<script src="../../../../fast/js/resources/js-test-pre.js"></script>
 6</head>
 7<body>
 8<p id="description"></p>
 9<input type="button" onfocus="log('focused first button')" value="1">
 10<input type="text" onfocus="log('focused text field')" value="2">
 11<input type="button" onfocus="log('focused second button')" value="3">
 12<div id="console"></div>
 13<script src="script-tests/focus-option-control-on-page.js"></script>
 14<script src="../../../../fast/js/resources/js-test-post.js"></script>
 15</body>
 16</html>

LayoutTests/platform/mac/fast/forms/script-tests/focus-option-control-on-page.js

 1description('https://bugs.webkit.org/show_bug.cgi?id=68412 - This test checks to see if option(alt)-tabbing properly focuses form elements that are normally not focused. For testing, the assumption is that by default pressing tab will skip over buttons, and option-tab will include buttons.');
 2
 3var iteration = 0;
 4var modifiers;
 5var result;
 6function startTest() {
 7 debug("Pressing tab 4 times:");
 8 modifiers = undefined;
 9 layoutTestController.focusWebView(runKeyPresses);
 10}
 11
 12function runKeyPresses() {
 13 result = '';
 14 for (var i = 0; i < 4; ++i) {
 15 result += ' /' + (i + 1) + ':';
 16 eventSender.keyDown("\t", modifiers);
 17 }
 18 iteration++;
 19 switch (iteration) {
 20 case 1:
 21 shouldBe('result', '" /1:focused text field /2: /3:focused text field /4:"');
 22 debug("Pressing shift-tab 4 times:");
 23 modifiers = ["shiftKey"];
 24 layoutTestController.focusWebView(runKeyPresses);
 25 break;
 26 case 2:
 27 shouldBe('result', '" /1:focused text field /2: /3:focused text field /4:"');
 28 debug("Pressing option-tab 4 times:");
 29 modifiers = ["altKey"];
 30 layoutTestController.focusWebView(runKeyPresses);
 31 break;
 32 case 3:
 33 shouldBe('result', '" /1:focused first button /2:focused text field /3:focused second button /4:"');
 34 debug("Pressing shift-option-tab 4 times:");
 35 modifiers = ["shiftKey", "altKey"];
 36 layoutTestController.focusWebView(runKeyPresses);
 37 break;
 38 case 4:
 39 shouldBe('result', '" /1:focused second button /2:focused text field /3:focused first button /4:"');
 40 layoutTestController.removeChromeInputField(notifyDone);
 41 break;
 42 }
 43}
 44
 45function notifyDone() {
 46 setTimeout(function() { layoutTestController.notifyDone(); }, 0);
 47}
 48
 49function log(val) {
 50 result += val;
 51}
 52
 53/////////////////////////////////
 54if (window.layoutTestController && window.eventSender && layoutTestController.addChromeInputField) {
 55 window.jsTestIsAsync = true;
 56 layoutTestController.addChromeInputField(startTest);
 57} else
 58 finishJSTest();
 59
 60var successfullyParsed = true;

Source/WebKit2/ChangeLog

 12011-10-03 Jon Lee <jonlee@apple.com>
 2
 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview
 4 https://bugs.webkit.org/show_bug.cgi?id=68412
 5 <rdar://problem/9988252>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 In WK1 setInitialFocus() is called on FocusController with the key event that
 10 caused the web view to become first responder. In WK2 no event is sent. So if
 11 the key stroke that caused the change in first responder status contains the
 12 option modifier key, FocusController did not know that it had to switch behavior.
 13
 14 Because there are multiple ways that the WKView can becomeFirstResponder, I changed
 15 the signature to setInitialFocus to express whether the key event parameter is an
 16 actual key event.
 17
 18 * UIProcess/API/C/win/WKView.cpp:
 19 (WKViewSetInitialFocus):
 20 * UIProcess/API/mac/WKView.mm:
 21 (-[WKView becomeFirstResponder]): Take the NSApp currentEvent and pass it along if
 22 the event is a keyboard event, otherwise pass an empty event.
 23 * UIProcess/WebPageProxy.cpp:
 24 (WebKit::WebPageProxy::setInitialFocus): Change in function signature to confirm that
 25 the event that caused the initial focus was a keyboard event, and provide the keyboard
 26 event itself.
 27 * UIProcess/WebPageProxy.h:
 28 * UIProcess/win/WebView.cpp:
 29 (WebKit::WebView::setInitialFocus):
 30 * UIProcess/win/WebView.h:
 31 * WebProcess/WebPage/WebPage.cpp:
 32 (WebKit::WebPage::setInitialFocus): If we know that the cause of this was a keyboard
 33 event, we pass that event to the FocusController. Otherwise we fall back to the original
 34 behavior, which is to pass no event at all.
 35 * WebProcess/WebPage/WebPage.h:
 36 * WebProcess/WebPage/WebPage.messages.in:
 37
 382011-09-23 Jon Lee <jonlee@apple.com>
 39
 40 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview
 41 https://bugs.webkit.org/show_bug.cgi?id=68412
 42 <rdar://problem/9988252>
 43
 44 Reviewed by NOBODY (OOPS!).
 45
 46 In WK1 setInitialFocus() is called on FocusController with the key event that
 47 caused the web view to become first responder. In WK2 no event is sent. So if
 48 the key stroke that caused the change in first responder status contains the
 49 option modifier key, FocusController did not know that it had to switch behavior.
 50
 51 Because there are multiple ways that the WKView can becomeFirstResponder, I changed
 52 the signature to setInitialFocus to express whether the key event parameter is an
 53 actual key event.
 54
 55 * UIProcess/API/C/win/WKView.cpp: Update function signature.
 56 (WKViewSetInitialFocus):
 57 * UIProcess/API/C/win/WKView.h:
 58
 59
1602011-10-03 Carlos Garcia Campos <cgarcia@igalia.com>
261
362 [GTK] Add failing uri parameter to provisional-load-failed and load-failed signals

Source/WebKit2/UIProcess/API/C/win/WKView.cpp

@@void WKViewSetIsInWindow(WKViewRef viewRef, bool isInWindow)
6969
7070void WKViewSetInitialFocus(WKViewRef viewRef, bool forward)
7171{
72  toImpl(viewRef)->setInitialFocus(forward);
 72 bool isKeyboardEventValid = false;
 73 toImpl(viewRef)->setInitialFocus(forward, isKeyboardEventValid, WebKeyboardEvent());
7374}
7475
7576void WKViewSetScrollOffsetOnNextResize(WKViewRef viewRef, WKSize scrollOffset)

Source/WebKit2/UIProcess/API/mac/WKView.mm

@@struct WKViewInterpretKeyEventsParameters {
304304- (BOOL)becomeFirstResponder
305305{
306306 NSSelectionDirection direction = [[self window] keyViewSelectionDirection];
307 
 307
308308 _data->_inBecomeFirstResponder = true;
309309
310310 [self _updateSecureInputState];
311311 _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
312 
 312
313313 _data->_inBecomeFirstResponder = false;
314 
315  if (direction != NSDirectSelection)
316  _data->_page->setInitialFocus(direction == NSSelectingNext);
317 
 314
 315 if (direction != NSDirectSelection) {
 316 NSEvent *event = [NSApp currentEvent];
 317 bool becomingFirstResponderFromKeyboard = [event type] == NSKeyDown || [event type] == NSKeyUp;
 318 if (!becomingFirstResponderFromKeyboard)
 319 event = nil;
 320 _data->_page->setInitialFocus(direction == NSSelectingNext, becomingFirstResponderFromKeyboard, NativeWebKeyboardEvent(event, self));
 321 }
318322 return YES;
319323}
320324

Source/WebKit2/UIProcess/WebPageProxy.cpp

@@IntSize WebPageProxy::viewSize() const
700700 return m_pageClient->viewSize();
701701}
702702
703 void WebPageProxy::setInitialFocus(bool forward)
 703void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
704704{
705705 if (!isValid())
706706 return;
707  process()->send(Messages::WebPage::SetInitialFocus(forward), m_pageID);
 707 process()->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
708708}
709709
710710void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)

Source/WebKit2/UIProcess/WebPageProxy.h

@@public:
262262 void viewWillStartLiveResize();
263263 void viewWillEndLiveResize();
264264
265  void setInitialFocus(bool);
 265 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
266266 void setWindowResizerSize(const WebCore::IntSize&);
267267
268268 void clearSelection();

Source/WebKit2/UIProcess/win/WebView.cpp

@@void WebView::setOverrideCursor(HCURSOR overrideCursor)
10681068 updateNativeCursor();
10691069}
10701070
1071 void WebView::setInitialFocus(bool forward)
 1071void WebView::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
10721072{
1073  m_page->setInitialFocus(forward);
 1073 m_page->setInitialFocus(forward, isKeyboardEventValid, event);
10741074}
10751075
10761076void WebView::setScrollOffsetOnNextResize(const IntSize& scrollOffset)

Source/WebKit2/UIProcess/win/WebView.h

@@public:
7979 void setIsInWindow(bool);
8080 void setIsVisible(bool);
8181 void setOverrideCursor(HCURSOR);
82  void setInitialFocus(bool forward);
 82 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
8383 void setScrollOffsetOnNextResize(const WebCore::IntSize&);
8484 void setFindIndicatorCallback(WKViewFindIndicatorCallback, void*);
8585 WKViewFindIndicatorCallback getFindIndicatorCallback(void**);

Source/WebKit2/WebProcess/WebPage/WebPage.cpp

@@void WebPage::setFocused(bool isFocused)
13651365 m_page->focusController()->setFocused(isFocused);
13661366}
13671367
1368 void WebPage::setInitialFocus(bool forward)
 1368void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
13691369{
13701370 if (!m_page || !m_page->focusController())
13711371 return;
13721372
13731373 Frame* frame = m_page->focusController()->focusedOrMainFrame();
13741374 frame->document()->setFocusedNode(0);
 1375
 1376 if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
 1377 PlatformKeyboardEvent platformEvent(platform(event));
 1378 platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown);
 1379 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get());
 1380 return;
 1381 }
 1382
13751383 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
13761384}
13771385

Source/WebKit2/WebProcess/WebPage/WebPage.h

@@private:
480480 void tryRestoreScrollPosition();
481481 void setActive(bool);
482482 void setFocused(bool);
483  void setInitialFocus(bool);
 483 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
484484 void setWindowResizerSize(const WebCore::IntSize&);
485485 void setIsInWindow(bool);
486486 void validateCommand(const String&, uint64_t);

Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

2323messages -> WebPage {
2424 SetActive(bool active)
2525 SetFocused(bool focused)
26  SetInitialFocus(bool forward)
 26 SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event)
2727 SetIsInWindow(bool isInWindow)
2828
2929 SetDrawsBackground(bool drawsBackground)

Tools/ChangeLog

 12011-10-03 Jon Lee <jonlee@apple.com>
 2
 3 REGRESSION (WK2): (Shift-)option-tabbing skips over elements when transitioning from chrome to webview
 4 https://bugs.webkit.org/show_bug.cgi?id=68412
 5 <rdar://problem/9988252>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 In order to create a test for the bug, I had to update DRT and WKTR to create some
 10 widget that allows first responder status to move away from the main web view.
 11
 12 Three methods were added to layoutTestController: addChromeInputField,
 13 removeChromeInputField, and focusWebView. addChromeInputField adds a text field
 14 that is a sibling to the web view, and sets up the key event loop between the two.
 15 removeChromeInputField removes that field. focusWebView moves first responder
 16 status to the web view.
 17
 18 The test makes the call via layoutTestController and passes a callback that it
 19 assumes will be executed once the task is completed. In DRT the callback is called
 20 synchronously. In WKTR this is handled with message passing between the two
 21 processes.
 22
 23 * DumpRenderTree/LayoutTestController.cpp:
 24 (addChromeInputFieldCallback):
 25 (removeChromeInputFieldCallback):
 26 (focusWebViewCallback):
 27 (LayoutTestController::staticFunctions):
 28 * DumpRenderTree/LayoutTestController.h:
 29 * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
 30 (LayoutTestController::addChromeInputField):
 31 (LayoutTestController::removeChromeInputField):
 32 (LayoutTestController::focusWebView):
 33 * DumpRenderTree/mac/DumpRenderTree.mm:
 34 (resetWebViewToConsistentStateBeforeTesting): When resetting for the next test,
 35 make sure to remove the chrome input field.
 36 * DumpRenderTree/mac/LayoutTestControllerMac.mm:
 37 (LayoutTestController::addChromeInputField):
 38 (LayoutTestController::removeChromeInputField):
 39 (LayoutTestController::focusWebView):
 40 * DumpRenderTree/win/LayoutTestControllerWin.cpp:
 41 (LayoutTestController::addChromeInputField):
 42 (LayoutTestController::removeChromeInputField):
 43 (LayoutTestController::focusWebView):
 44 * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
 45 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
 46 (WTR::InjectedBundle::didReceiveMessage):
 47 (WTR::InjectedBundle::postAddChromeInputField):
 48 (WTR::InjectedBundle::postRemoveChromeInputField):
 49 (WTR::InjectedBundle::postFocusWebView):
 50 * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
 51 * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
 52 (WTR::callbackMap): Create a hash map that keeps track of the callbacks provided
 53 through JS.
 54 (WTR::cacheLayoutTestControllerCallback):
 55 (WTR::callLayoutTestControllerCallback):
 56 (WTR::LayoutTestController::addChromeInputField):
 57 (WTR::LayoutTestController::removeChromeInputField):
 58 (WTR::LayoutTestController::focusWebView):
 59 (WTR::LayoutTestController::callAddChromeInputFieldCallback):
 60 (WTR::LayoutTestController::callRemoveChromeInputFieldCallback):
 61 (WTR::LayoutTestController::callFocusWebViewCallback):
 62 * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
 63 * WebKitTestRunner/PlatformWebView.h:
 64 * WebKitTestRunner/TestController.cpp:
 65 (WTR::TestController::resetStateToConsistentValues):
 66 * WebKitTestRunner/TestInvocation.cpp:
 67 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
 68 * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
 69 (WTR::PlatformWebView::addChromeInputField):
 70 (WTR::PlatformWebView::removeChromeInputField):
 71 (WTR::PlatformWebView::makeWebViewFirstResponder):
 72 * WebKitTestRunner/mac/PlatformWebViewMac.mm:
 73 (WTR::PlatformWebView::addChromeInputField):
 74 (WTR::PlatformWebView::removeChromeInputField):
 75 (WTR::PlatformWebView::makeWebViewFirstResponder):
 76 * WebKitTestRunner/win/PlatformWebViewWin.cpp:
 77 (WTR::PlatformWebView::addChromeInputField):
 78 (WTR::PlatformWebView::removeChromeInputField):
 79 (WTR::PlatformWebView::makeWebViewFirstResponder):
 80
 81 * DumpRenderTree/mac/LayoutTestControllerMac.mm: These functions have nothing to do
 82 with the patch-- just cleaning up style.
 83 (LayoutTestController::addDisallowedURL):
 84 (originsArrayToJS):
 85 (LayoutTestController::queueLoad):
 86 (LayoutTestController::setMockDeviceOrientation):
 87 (LayoutTestController::setIconDatabaseEnabled):
 88 (LayoutTestController::setEditingBehavior):
 89
1902011-10-03 Carlos Garcia Campos <cgarcia@igalia.com>
291
392 [GTK] Fix memory leak when loading url

Tools/DumpRenderTree/LayoutTestController.cpp

@@static JSValueRef setShouldStayOnPageAfterHandlingBeforeUnloadCallback(JSContext
21602160 return JSValueMakeUndefined(context);
21612161}
21622162
 2163static JSValueRef addChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 2164{
 2165 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
 2166 controller->addChromeInputField();
 2167 // the first argument is a callback that is called once the input field has been added
 2168 if (argumentCount == 1)
 2169 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
 2170 return JSValueMakeUndefined(context);
 2171}
 2172
 2173static JSValueRef removeChromeInputFieldCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 2174{
 2175 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
 2176 controller->removeChromeInputField();
 2177 // the first argument is a callback that is called once the input field has been added
 2178 if (argumentCount == 1)
 2179 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
 2180 return JSValueMakeUndefined(context);
 2181}
 2182
 2183static JSValueRef focusWebViewCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 2184{
 2185 LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
 2186 controller->focusWebView();
 2187 // the first argument is a callback that is called once the input field has been added
 2188 if (argumentCount == 1)
 2189 JSObjectCallAsFunction(context, JSValueToObject(context, arguments[0], 0), thisObject, 0, 0, 0);
 2190 return JSValueMakeUndefined(context);
 2191}
 2192
21632193// Static Values
21642194
21652195static JSValueRef getGlobalFlagCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)

@@JSStaticFunction* LayoutTestController::staticFunctions()
24362466 { "setTextDirection", setTextDirectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24372467 { "allowRoundingHacks", allowRoundingHacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24382468 { "setShouldStayOnPageAfterHandlingBeforeUnload", setShouldStayOnPageAfterHandlingBeforeUnloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2469 { "addChromeInputField", addChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2470 { "removeChromeInputField", removeChromeInputFieldCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 2471 { "focusWebView", focusWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
24392472 { 0, 0, 0 }
24402473 };
24412474

Tools/DumpRenderTree/LayoutTestController.h

@@public:
314314 bool shouldStayOnPageAfterHandlingBeforeUnload() const { return m_shouldStayOnPageAfterHandlingBeforeUnload; }
315315 void setShouldStayOnPageAfterHandlingBeforeUnload(bool shouldStayOnPageAfterHandlingBeforeUnload) { m_shouldStayOnPageAfterHandlingBeforeUnload = shouldStayOnPageAfterHandlingBeforeUnload; }
316316
 317 void addChromeInputField();
 318 void removeChromeInputField();
 319 void focusWebView();
 320
317321 void setPOSIXLocale(JSStringRef locale);
318322
319323 void setWebViewEditable(bool);

Tools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

@@void LayoutTestController::setTextDirection(JSStringRef direction)
987987void LayoutTestController::allowRoundingHacks()
988988{
989989}
 990
 991void LayoutTestController::addChromeInputField()
 992{
 993}
 994
 995void LayoutTestController::removeChromeInputField()
 996{
 997}
 998
 999void LayoutTestController::focusWebView()
 1000{
 1001}

Tools/DumpRenderTree/mac/DumpRenderTree.mm

@@static void resetWebViewToConsistentStateBeforeTesting()
11631163
11641164 resetDefaultsToConsistentValues();
11651165
1166  if (gLayoutTestController)
 1166 if (gLayoutTestController) {
11671167 WebCoreTestSupport::resetInternalsObject([mainFrame globalContext]);
 1168 // in the case that a test using the chrome input field failed, be sure to clean up for the next test
 1169 gLayoutTestController->removeChromeInputField();
 1170 }
11681171
11691172 [[mainFrame webView] setSmartInsertDeleteEnabled:YES];
11701173 [[[mainFrame webView] inspector] setJavaScriptProfilingEnabled:NO];

Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm

@@void LayoutTestController::addDisallowedURL(JSStringRef url)
119119 disallowedURLs = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL);
120120
121121 // Canonicalize the URL
122  NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]];
 122 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]];
123123 request = [NSURLProtocol canonicalRequestForRequest:request];
124124
125125 CFSetAddValue(disallowedURLs, [request URL]);

@@void LayoutTestController::clearApplicationCacheForOrigin(JSStringRef url)
168168 [origin release];
169169}
170170
171 JSValueRef originsArrayToJS(JSContextRef context, NSArray* origins)
 171JSValueRef originsArrayToJS(JSContextRef context, NSArray *origins)
172172{
173173 NSUInteger count = [origins count];
174174

@@void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
425425 NSString *urlNS = (NSString *)urlCF.get();
426426
427427 NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]];
428  NSString* nsurlString = [nsurl absoluteString];
 428 NSString *nsurlString = [nsurl absoluteString];
429429
430430 JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString([nsurlString UTF8String]));
431431 WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));

@@void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double
508508{
509509 // DumpRenderTree configured the WebView to use WebDeviceOrientationProviderMock.
510510 id<WebDeviceOrientationProvider> provider = [[mainFrame webView] _deviceOrientationProvider];
511  WebDeviceOrientationProviderMock* mockProvider = static_cast<WebDeviceOrientationProviderMock*>(provider);
512  WebDeviceOrientation* orientation = [[WebDeviceOrientation alloc] initWithCanProvideAlpha:canProvideAlpha alpha:alpha canProvideBeta:canProvideBeta beta:beta canProvideGamma:canProvideGamma gamma:gamma];
 511 WebDeviceOrientationProviderMock *mockProvider = static_cast<WebDeviceOrientationProviderMock*>(provider);
 512 WebDeviceOrientation *orientation = [[WebDeviceOrientation alloc] initWithCanProvideAlpha:canProvideAlpha alpha:alpha canProvideBeta:canProvideBeta beta:beta canProvideGamma:canProvideGamma gamma:gamma];
513513 [mockProvider setOrientation:orientation];
514514 [orientation release];
515515}

@@void LayoutTestController::startSpeechInput(JSContextRef inputElement)
550550void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled)
551551{
552552 // FIXME: Workaround <rdar://problem/6480108>
553  static WebIconDatabase* sharedWebIconDatabase = NULL;
 553 static WebIconDatabase *sharedWebIconDatabase = NULL;
554554 if (!sharedWebIconDatabase) {
555555 if (!iconDatabaseEnabled)
556556 return;

@@void LayoutTestController::authenticateSession(JSStringRef url, JSStringRef user
11511151
11521152void LayoutTestController::setEditingBehavior(const char* editingBehavior)
11531153{
1154  NSString* editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior];
 1154 NSString *editingBehaviorNS = [[NSString alloc] initWithUTF8String:editingBehavior];
11551155 if ([editingBehaviorNS isEqualToString:@"mac"])
11561156 [[WebPreferences standardPreferences] setEditingBehavior:WebKitEditingMacBehavior];
11571157 else if ([editingBehaviorNS isEqualToString:@"win"])

@@void LayoutTestController::setTextDirection(JSStringRef directionName)
12021202 ASSERT_NOT_REACHED();
12031203#endif
12041204}
 1205
 1206void LayoutTestController::addChromeInputField()
 1207{
 1208 NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
 1209 textField.tag = 1;
 1210 [[[[mainFrame webView] window] contentView] addSubview:textField];
 1211 [textField release];
 1212
 1213 [textField setNextKeyView:[mainFrame webView]];
 1214 [[mainFrame webView] setNextKeyView:textField];
 1215}
 1216
 1217void LayoutTestController::removeChromeInputField()
 1218{
 1219 NSView* textField = [[[[mainFrame webView] window] contentView] viewWithTag:1];
 1220 if (textField) {
 1221 [textField removeFromSuperview];
 1222 focusWebView();
 1223 }
 1224}
 1225
 1226void LayoutTestController::focusWebView()
 1227{
 1228 [[[mainFrame webView] window] makeFirstResponder:[mainFrame webView]];
 1229}

Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp

@@void LayoutTestController::setTextDirection(JSStringRef direction)
15401540void LayoutTestController::allowRoundingHacks()
15411541{
15421542}
 1543
 1544void LayoutTestController::addChromeInputField()
 1545{
 1546}
 1547
 1548void LayoutTestController::removeChromeInputField()
 1549{
 1550}
 1551
 1552void LayoutTestController::focusWebView()
 1553{
 1554}

Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl

@@module WTR {
121121 void setWillSendRequestReturnsNull(in boolean flag);
122122
123123 void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);
 124
 125 // Focus testing.
 126 void addChromeInputField(in object callback);
 127 void removeChromeInputField(in object callback);
 128 void focusWebView(in object callback);
124129 };
125130
126131}

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

@@void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
158158
159159 return;
160160 }
 161 if (WKStringIsEqualToUTF8CString(messageName, "CallAddChromeInputFieldCallback")) {
 162 m_layoutTestController->callAddChromeInputFieldCallback();
 163 return;
 164 }
 165 if (WKStringIsEqualToUTF8CString(messageName, "CallRemoveChromeInputFieldCallback")) {
 166 m_layoutTestController->callRemoveChromeInputFieldCallback();
 167 return;
 168 }
 169 if (WKStringIsEqualToUTF8CString(messageName, "CallFocusWebViewCallback")) {
 170 m_layoutTestController->callFocusWebViewCallback();
 171 return;
 172 }
161173
162174 WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error"));
163175 WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown"));

@@void InjectedBundle::postNewBeforeUnloadReturnValue(bool value)
246258 WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
247259}
248260
 261void InjectedBundle::postAddChromeInputField()
 262{
 263 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AddChromeInputField"));
 264 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 265}
 266
 267void InjectedBundle::postRemoveChromeInputField()
 268{
 269 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RemoveChromeInputField"));
 270 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 271}
 272
 273void InjectedBundle::postFocusWebView()
 274{
 275 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("FocusWebView"));
 276 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 277}
 278
249279} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

@@public:
7474 bool shouldDumpPixels() const { return m_dumpPixels; }
7575
7676 void postNewBeforeUnloadReturnValue(bool);
 77 void postAddChromeInputField();
 78 void postRemoveChromeInputField();
 79 void postFocusWebView();
7780
7881private:
7982 InjectedBundle();

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp

@@void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(bool sho
513513 InjectedBundle::shared().postNewBeforeUnloadReturnValue(!shouldStayOnPage);
514514}
515515
 516typedef WTF::HashMap<unsigned, JSValueRef> CallbackMap;
 517static CallbackMap& callbackMap()
 518{
 519 static CallbackMap& map = *new CallbackMap;
 520 return map;
 521}
 522
 523static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback)
 524{
 525 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 526 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 527 JSValueProtect(context, callback);
 528 callbackMap().add(index, callback);
 529}
 530
 531static void callLayoutTestControllerCallback(unsigned index)
 532{
 533 if (!callbackMap().contains(index))
 534 return;
 535 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 536 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 537 JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
 538 JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
 539 JSValueUnprotect(context, callback);
 540}
 541
 542void LayoutTestController::addChromeInputField(JSValueRef callback)
 543{
 544 cacheLayoutTestControllerCallback(1, callback);
 545 InjectedBundle::shared().postAddChromeInputField();
 546}
 547
 548void LayoutTestController::removeChromeInputField(JSValueRef callback)
 549{
 550 cacheLayoutTestControllerCallback(2, callback);
 551 InjectedBundle::shared().postRemoveChromeInputField();
 552}
 553
 554void LayoutTestController::focusWebView(JSValueRef callback)
 555{
 556 cacheLayoutTestControllerCallback(3, callback);
 557 InjectedBundle::shared().postFocusWebView();
 558}
 559
 560void LayoutTestController::callAddChromeInputFieldCallback()
 561{
 562 callLayoutTestControllerCallback(1);
 563}
 564
 565void LayoutTestController::callRemoveChromeInputFieldCallback()
 566{
 567 callLayoutTestControllerCallback(2);
 568}
 569
 570void LayoutTestController::callFocusWebViewCallback()
 571{
 572 callLayoutTestControllerCallback(3);
 573}
 574
516575} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

@@public:
176176
177177 bool globalFlag() const { return m_globalFlag; }
178178 void setGlobalFlag(bool value) { m_globalFlag = value; }
 179
 180 void addChromeInputField(JSValueRef);
 181 void removeChromeInputField(JSValueRef);
 182 void focusWebView(JSValueRef);
 183 void callAddChromeInputFieldCallback();
 184 void callRemoveChromeInputFieldCallback();
 185 void callFocusWebViewCallback();
179186
180187private:
181188 static const double waitToDumpWatchdogTimerInterval;

Tools/WebKitTestRunner/PlatformWebView.h

@@public:
7070
7171 WKRect windowFrame();
7272 void setWindowFrame(WKRect);
 73
 74 void addChromeInputField();
 75 void removeChromeInputField();
 76 void makeWebViewFirstResponder();
7377
7478private:
7579 PlatformWKView m_view;

Tools/WebKitTestRunner/TestController.cpp

@@bool TestController::resetStateToConsistentValues()
426426 WKPreferencesSetSerifFontFamily(preferences, serifFontFamily);
427427#endif
428428
 429 // in the case that a test using the chrome input field failed, be sure to clean up for the next test
 430 m_mainWebView->removeChromeInputField();
429431 m_mainWebView->focus();
430432
431433 // Reset main page back to about:blank

Tools/WebKitTestRunner/TestInvocation.cpp

@@void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
248248 TestController::shared().setBeforeUnloadReturnValue(WKBooleanGetValue(beforeUnloadReturnValue));
249249 return;
250250 }
 251
 252 if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) {
 253 TestController::shared().mainWebView()->addChromeInputField();
 254 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback"));
 255 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 256 return;
 257 }
 258
 259 if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) {
 260 TestController::shared().mainWebView()->removeChromeInputField();
 261 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback"));
 262 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 263 return;
 264 }
 265
 266 if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) {
 267 TestController::shared().mainWebView()->makeWebViewFirstResponder();
 268 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback"));
 269 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 270 return;
 271 }
251272
252273 ASSERT_NOT_REACHED();
253274}

Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp

@@void PlatformWebView::setWindowFrame(WKRect frame)
9797 resizeTo(frame.size.width, frame.size.height);
9898}
9999
 100void PlatformWebView::addChromeInputField()
 101{
 102}
 103
 104void PlatformWebView::removeChromeInputField()
 105{
 106}
 107
 108void PlatformWebView::makeWebViewFirstResponder()
 109{
 110}
 111
100112} // namespace WTR
101113

Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

@@void PlatformWebView::setWindowFrame(WKRect frame)
8080 [m_window setFrame:NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height) display:YES];
8181}
8282
 83void PlatformWebView::addChromeInputField()
 84{
 85 NSTextField* textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 20)];
 86 textField.tag = 1;
 87 [[m_window contentView] addSubview:textField];
 88 [textField release];
 89
 90 [textField setNextKeyView:m_view];
 91 [m_view setNextKeyView:textField];
 92}
 93
 94void PlatformWebView::removeChromeInputField()
 95{
 96 NSView* textField = [[m_window contentView] viewWithTag:1];
 97 if (textField) {
 98 [textField removeFromSuperview];
 99 makeWebViewFirstResponder();
 100 }
 101}
 102
 103void PlatformWebView::makeWebViewFirstResponder()
 104{
 105 [m_window makeFirstResponder:m_view];
 106}
 107
83108} // namespace WTR

Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp

@@void PlatformWebView::setWindowFrame(WKRect)
9797 // Implement.
9898}
9999
 100
 101void PlatformWebView::addChromeInputField()
 102{
 103}
 104
 105void PlatformWebView::removeChromeInputField()
 106{
 107}
 108
 109void PlatformWebView::makeWebViewFirstResponder()
 110{
 111}
 112
100113} // namespace WTR