LayoutTests/ChangeLog

 12011-09-22 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 * fast/forms/focus-option-control-on-page-expected.txt: Added.
 10 * fast/forms/focus-option-control-on-page.html: Added.
 11
1122011-09-22 David Hyatt <hyatt@apple.com>
213
314 https://bugs.webkit.org/show_bug.cgi?id=68650

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

 1<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
 3
 4Tab:
 50:2
 61:
 72:2
 83:
 9Shift-tab:
 100:2
 111:
 122:2
 133:
 14Option-tab:
 150:1
 161:2
 172:3
 183:
 19Shift-option-tab:
 200:3
 211:2
 222:1
 233:

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

 1<p>&lt;https://bugs.webkit.org/show_bug.cgi?id=68412&gt; 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.</p>
 2<hr>
 3<input type="button" onfocus="log(1)" value="button">
 4<input type="text" id="textField" onfocus="log(2)" value="text">
 5<input type="button" onfocus="log(3)" value="button">
 6<hr>
 7<p id="log"></p>
 8
 9<script>
 10
 11function log(str)
 12{
 13 document.getElementById("log").innerHTML += str;
 14}
 15
 16window.onload = function()
 17{
 18 if (!window.layoutTestController || !window.eventSender)
 19 return;
 20
 21 if (!layoutTestController.addChromeInputField)
 22 return;
 23
 24 layoutTestController.dumpAsText();
 25 layoutTestController.waitUntilDone();
 26 layoutTestController.addChromeInputField(startTest);
 27}
 28
 29var iteration = 0;
 30var modifiers;
 31function startTest() {
 32 log("Tab:");
 33 modifiers = undefined;
 34 layoutTestController.focusWebView(runKeyPresses);
 35 setTimeout(function() {layoutTestController.removeChromeInputField(notifyDone)}, 2000);
 36}
 37
 38function runKeyPresses() {
 39 for (var i = 0; i < 4; ++i) {
 40 log("<br/>" + i + ":");
 41 eventSender.keyDown("\t", modifiers);
 42 }
 43
 44 iteration++;
 45 switch (iteration) {
 46 case 1:
 47 log("<br/>Shift-tab:");
 48 modifiers = ["shiftKey"];
 49 layoutTestController.focusWebView(runKeyPresses);
 50 break;
 51 case 2:
 52 log("<br/>Option-tab:");
 53 modifiers = ["altKey"];
 54 layoutTestController.focusWebView(runKeyPresses);
 55 break;
 56 case 3:
 57 log("<br/>Shift-option-tab:");
 58 modifiers = ["shiftKey", "altKey"];
 59 layoutTestController.focusWebView(runKeyPresses);
 60 break;
 61 case 4:
 62 layoutTestController.removeChromeInputField(notifyDone);
 63 break;
 64 }
 65}
 66
 67function notifyDone() {
 68 layoutTestController.notifyDone();
 69}
 70</script>

Source/WebKit2/ChangeLog

 12011-09-22 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/mac/WKView.mm:
 19 (-[WKView becomeFirstResponder]): Take the NSApp currentEvent and pass it along if
 20 the event is a keyboard event, otherwise pass an empty event.
 21 * UIProcess/WebPageProxy.cpp:
 22 (WebKit::WebPageProxy::setInitialFocus): Change in function signature to confirm that
 23 the event that caused the initial focus was a keyboard event, and provide the keyboard
 24 event itself.
 25 * UIProcess/WebPageProxy.h:
 26 * UIProcess/win/WebView.cpp:
 27 (WebKit::WebView::setInitialFocus):
 28 * UIProcess/win/WebView.h:
 29 * WebProcess/WebPage/WebPage.cpp:
 30 (WebKit::WebPage::setInitialFocus): If we know that the cause of this was a keyboard
 31 event, we pass that event to the FocusController. Otherwise we fall back to the original
 32 behavior, which is to pass no event at all.
 33 * WebProcess/WebPage/WebPage.h:
 34 * WebProcess/WebPage/WebPage.messages.in:
 35
1362011-09-22 Alexey Proskuryakov <ap@apple.com>
237
338 [WK2] UIProcess should check that WebProcess isn't sending unexpected file: URLs to it

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)
13111311 m_page->focusController()->setFocused(isFocused);
13121312}
13131313
1314 void WebPage::setInitialFocus(bool forward)
 1314void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
13151315{
13161316 if (!m_page || !m_page->focusController())
13171317 return;
13181318
 1319
13191320 Frame* frame = m_page->focusController()->focusedOrMainFrame();
13201321 frame->document()->setFocusedNode(0);
1321  m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
 1322
 1323 if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
 1324 PlatformKeyboardEvent platformEvent(platform(event));
 1325 platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown);
 1326 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get());
 1327 } else
 1328 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
13221329}
13231330
13241331void WebPage::setWindowResizerSize(const IntSize& windowResizerSize)

Source/WebKit2/WebProcess/WebPage/WebPage.h

@@private:
468468 void tryRestoreScrollPosition();
469469 void setActive(bool);
470470 void setFocused(bool);
471  void setInitialFocus(bool);
 471 void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
472472 void setWindowResizerSize(const WebCore::IntSize&);
473473 void setIsInWindow(bool);
474474 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-09-22 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/LayoutTestControllerMac.mm:
 34 (LayoutTestController::addChromeInputField):
 35 (LayoutTestController::removeChromeInputField):
 36 (LayoutTestController::focusWebView):
 37 * DumpRenderTree/win/LayoutTestControllerWin.cpp:
 38 (LayoutTestController::addChromeInputField):
 39 (LayoutTestController::removeChromeInputField):
 40 (LayoutTestController::focusWebView):
 41 * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
 42 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
 43 (WTR::InjectedBundle::didReceiveMessage):
 44 (WTR::InjectedBundle::postAddChromeInputField):
 45 (WTR::InjectedBundle::postRemoveChromeInputField):
 46 (WTR::InjectedBundle::postFocusWebView):
 47 * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
 48 * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
 49 (WTR::callbackMap): Create a hash map that keeps track of the callbacks provided
 50 through JS.
 51 (WTR::cacheLayoutTestControllerCallback):
 52 (WTR::callLayoutTestControllerCallback):
 53 (WTR::LayoutTestController::addChromeInputField):
 54 (WTR::LayoutTestController::removeChromeInputField):
 55 (WTR::LayoutTestController::focusWebView):
 56 (WTR::LayoutTestController::callAddChromeInputFieldCallback):
 57 (WTR::LayoutTestController::callRemoveChromeInputFieldCallback):
 58 (WTR::LayoutTestController::callFocusWebViewCallback):
 59 * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
 60 * WebKitTestRunner/PlatformWebView.h:
 61 * WebKitTestRunner/TestInvocation.cpp:
 62 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
 63 * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
 64 (WTR::PlatformWebView::addChromeInputField):
 65 (WTR::PlatformWebView::removeChromeInputField):
 66 (WTR::PlatformWebView::makeWebViewFirstResponder):
 67 * WebKitTestRunner/mac/PlatformWebViewMac.mm:
 68 (WTR::PlatformWebView::addChromeInputField):
 69 (WTR::PlatformWebView::removeChromeInputField):
 70 (WTR::PlatformWebView::makeWebViewFirstResponder):
 71 * WebKitTestRunner/win/PlatformWebViewWin.cpp:
 72 (WTR::LayoutTestController::addChromeInputField):
 73 (WTR::LayoutTestController::removeChromeInputField):
 74 (WTR::LayoutTestController::makeWebViewFirstResponder):
 75
1762011-09-22 Adam Roben <aroben@apple.com>
277
378 Remove FindSafari

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/LayoutTestControllerMac.mm

@@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 [[[[[mainFrame webView] window] contentView] viewWithTag:1] removeFromSuperview];
 1220 focusWebView();
 1221}
 1222
 1223void LayoutTestController::focusWebView()
 1224{
 1225 [[[mainFrame webView] window] makeFirstResponder:[mainFrame webView]];
 1226}

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 {
117117 void setWillSendRequestReturnsNull(in boolean flag);
118118
119119 void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag);
 120
 121 // Focus testing.
 122 void addChromeInputField(in object callback);
 123 void removeChromeInputField(in object callback);
 124 void focusWebView(in object callback);
120125 };
121126
122127}

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)
241253 WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
242254}
243255
 256void InjectedBundle::postAddChromeInputField()
 257{
 258 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("AddChromeInputField"));
 259 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 260}
 261
 262void InjectedBundle::postRemoveChromeInputField()
 263{
 264 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("RemoveChromeInputField"));
 265 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 266}
 267
 268void InjectedBundle::postFocusWebView()
 269{
 270 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("FocusWebView"));
 271 WKBundlePostMessage(m_bundle, messageName.get(), 0);
 272}
 273
244274} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

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

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp

@@void LayoutTestController::setShouldStayOnPageAfterHandlingBeforeUnload(bool sho
500500 InjectedBundle::shared().postNewBeforeUnloadReturnValue(!shouldStayOnPage);
501501}
502502
 503typedef WTF::HashMap<unsigned, JSValueRef> CallbackMap;
 504static CallbackMap& callbackMap()
 505{
 506 static CallbackMap& map = *new CallbackMap;
 507 return map;
 508}
 509
 510static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback)
 511{
 512 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 513 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 514 JSValueProtect(context, callback);
 515 callbackMap().add(index, callback);
 516}
 517
 518static void callLayoutTestControllerCallback(unsigned index)
 519{
 520 if (!callbackMap().contains(index))
 521 return;
 522 WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
 523 JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
 524 JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
 525 JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
 526 JSValueUnprotect(context, callback);
 527}
 528
 529void LayoutTestController::addChromeInputField(JSValueRef callback)
 530{
 531 cacheLayoutTestControllerCallback(1, callback);
 532 InjectedBundle::shared().postAddChromeInputField();
 533}
 534
 535void LayoutTestController::removeChromeInputField(JSValueRef callback)
 536{
 537 cacheLayoutTestControllerCallback(2, callback);
 538 InjectedBundle::shared().postRemoveChromeInputField();
 539}
 540
 541void LayoutTestController::focusWebView(JSValueRef callback)
 542{
 543 cacheLayoutTestControllerCallback(3, callback);
 544 InjectedBundle::shared().postFocusWebView();
 545}
 546
 547void LayoutTestController::callAddChromeInputFieldCallback()
 548{
 549 callLayoutTestControllerCallback(1);
 550}
 551
 552void LayoutTestController::callRemoveChromeInputFieldCallback()
 553{
 554 callLayoutTestControllerCallback(2);
 555}
 556
 557void LayoutTestController::callFocusWebViewCallback()
 558{
 559 callLayoutTestControllerCallback(3);
 560}
 561
503562} // namespace WTR

Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

@@public:
172172
173173 bool globalFlag() const { return m_globalFlag; }
174174 void setGlobalFlag(bool value) { m_globalFlag = value; }
 175
 176 void addChromeInputField(JSValueRef);
 177 void removeChromeInputField(JSValueRef);
 178 void focusWebView(JSValueRef);
 179 void callAddChromeInputFieldCallback();
 180 void callRemoveChromeInputFieldCallback();
 181 void callFocusWebViewCallback();
175182
176183private:
177184 static const double waitToDumpWatchdogTimerInterval;

Tools/WebKitTestRunner/PlatformWebView.h

@@public:
7171
7272 WKRect windowFrame();
7373 void setWindowFrame(WKRect);
 74
 75 void addChromeInputField();
 76 void removeChromeInputField();
 77 void makeWebViewFirstResponder();
7478
7579private:
7680 PlatformWKView m_view;

Tools/WebKitTestRunner/TestInvocation.cpp

@@void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
245245 TestController::shared().setBeforeUnloadReturnValue(WKBooleanGetValue(beforeUnloadReturnValue));
246246 return;
247247 }
 248
 249 if (WKStringIsEqualToUTF8CString(messageName, "AddChromeInputField")) {
 250 TestController::shared().mainWebView()->addChromeInputField();
 251 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallAddChromeInputFieldCallback"));
 252 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 253 return;
 254 }
 255
 256 if (WKStringIsEqualToUTF8CString(messageName, "RemoveChromeInputField")) {
 257 TestController::shared().mainWebView()->removeChromeInputField();
 258 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallRemoveChromeInputFieldCallback"));
 259 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 260 return;
 261 }
 262
 263 if (WKStringIsEqualToUTF8CString(messageName, "FocusWebView")) {
 264 TestController::shared().mainWebView()->makeWebViewFirstResponder();
 265 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallFocusWebViewCallback"));
 266 WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), 0);
 267 return;
 268 }
248269
249270 ASSERT_NOT_REACHED();
250271}

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 [[[m_window contentView] viewWithTag:1] removeFromSuperview];
 97 makeWebViewFirstResponder();
 98}
 99
 100void PlatformWebView::makeWebViewFirstResponder()
 101{
 102 [m_window makeFirstResponder:m_view];
 103}
 104
83105} // namespace WTR

Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp

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