[iOS WK2] WTR fails to set the key window in the UIKit sense
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:58:40 +0000 (01:58 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:58:40 +0000 (01:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149325

Reviewed by Tim Horton.

-[WebKitTestRunnerWindow isKeyWindow] just returned _platformWebView->windowIsKey().
This causes UIKit to bypass code that actually sets the key window, resulting in
[UIAppliation sharedApplication].keyWindow always being nil.

Fix by PlatformWebView::setWindowIsKey() actually call -makeKeyWindow, and having
-[WebKitTestRunnerWindow isKeyWindow] call super.

* WebKitTestRunner/PlatformWebView.h:
(WTR::PlatformWebView::setWindowIsKey): Deleted.
* WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
(WTR::PlatformWebView::setWindowIsKey):
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::setWindowIsKey):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(-[WebKitTestRunnerWindow isKeyWindow]):
(WTR::PlatformWebView::PlatformWebView):
(WTR::PlatformWebView::~PlatformWebView):
(WTR::PlatformWebView::setWindowIsKey):
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::setWindowIsKey):

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

Tools/ChangeLog
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp
Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

index 5cacd7a..ab4e0b0 100644 (file)
@@ -1,5 +1,33 @@
 2015-09-17  Simon Fraser  <simon.fraser@apple.com>
 
+        [iOS WK2] WTR fails to set the key window in the UIKit sense
+        https://bugs.webkit.org/show_bug.cgi?id=149325
+
+        Reviewed by Tim Horton.
+
+        -[WebKitTestRunnerWindow isKeyWindow] just returned _platformWebView->windowIsKey().
+        This causes UIKit to bypass code that actually sets the key window, resulting in
+        [UIAppliation sharedApplication].keyWindow always being nil.
+
+        Fix by PlatformWebView::setWindowIsKey() actually call -makeKeyWindow, and having
+        -[WebKitTestRunnerWindow isKeyWindow] call super.
+
+        * WebKitTestRunner/PlatformWebView.h:
+        (WTR::PlatformWebView::setWindowIsKey): Deleted.
+        * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
+        (WTR::PlatformWebView::setWindowIsKey):
+        * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
+        (WTR::PlatformWebView::setWindowIsKey):
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (-[WebKitTestRunnerWindow isKeyWindow]):
+        (WTR::PlatformWebView::PlatformWebView):
+        (WTR::PlatformWebView::~PlatformWebView):
+        (WTR::PlatformWebView::setWindowIsKey):
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (WTR::PlatformWebView::setWindowIsKey):
+
+2015-09-17  Simon Fraser  <simon.fraser@apple.com>
+
         [iOS WK2] When loading viewport tests, use the normal web page viewport configuration
         https://bugs.webkit.org/show_bug.cgi?id=149321
 
index 52c8beb..9056df3 100644 (file)
@@ -77,7 +77,7 @@ public:
     void addChromeInputField();
     void removeChromeInputField();
     void makeWebViewFirstResponder();
-    void setWindowIsKey(bool isKey) { m_windowIsKey = isKey; }
+    void setWindowIsKey(bool);
     bool windowIsKey() const { return m_windowIsKey; }
 
     bool viewSupportsOptions(const TestOptions&) const;
index b222d60..61c4938 100644 (file)
@@ -82,6 +82,11 @@ PlatformWebView::~PlatformWebView()
     ecore_evas_free(m_window);
 }
 
+void PlatformWebView::setWindowIsKey(bool isKey)
+{
+    m_windowIsKey = isKey;
+}
+
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
     // FIXME: Don't we need to resize the window too?
index ff18f84..0664730 100644 (file)
@@ -58,6 +58,11 @@ PlatformWebView::~PlatformWebView()
     gtk_widget_destroy(m_window);
 }
 
+void PlatformWebView::setWindowIsKey(bool isKey)
+{
+    m_windowIsKey = isKey;
+}
+
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
     WKRect frame = windowFrame();
index ecb0cd3..6207282 100644 (file)
 
     return self;
 }
+
 - (BOOL)isKeyWindow
 {
-    return _platformWebView ? _platformWebView->windowIsKey() : YES;
+    return [super isKeyWindow] && (_platformWebView ? _platformWebView->windowIsKey() : YES);
 }
 
 - (void)setFrameOrigin:(CGPoint)point
@@ -107,14 +108,27 @@ PlatformWebView::PlatformWebView(WKWebViewConfiguration* configuration, const Te
     CGRect rect = CGRectMake(0, 0, TestController::viewWidth, TestController::viewHeight);
     m_view = [[WKWebView alloc] initWithFrame:rect configuration:configuration];
 
-    CGRect windowRect = rect;
-    m_window = [[WebKitTestRunnerWindow alloc] initWithFrame:windowRect];
+    m_window = [[WebKitTestRunnerWindow alloc] initWithFrame:rect];
     m_window.platformWebView = this;
 
     [m_window addSubview:m_view];
     [m_window makeKeyAndVisible];
 }
 
+PlatformWebView::~PlatformWebView()
+{
+    m_window.platformWebView = nil;
+    [m_view release];
+    [m_window release];
+}
+
+void PlatformWebView::setWindowIsKey(bool isKey)
+{
+    m_windowIsKey = isKey;
+    if (isKey)
+        [m_window makeKeyWindow];
+}
+
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
     WKRect frame = windowFrame();
@@ -123,13 +137,6 @@ void PlatformWebView::resizeTo(unsigned width, unsigned height)
     setWindowFrame(frame);
 }
 
-PlatformWebView::~PlatformWebView()
-{
-    m_window.platformWebView = 0;
-    [m_view release];
-    [m_window release];
-}
-
 WKPageRef PlatformWebView::page()
 {
     return [m_view _pageForTesting];
index 0e40bb1..caae5d0 100644 (file)
@@ -145,6 +145,11 @@ PlatformWebView::PlatformWebView(WKWebViewConfiguration* configuration, const Te
 #endif
 }
 
+void PlatformWebView::setWindowIsKey(bool isKey)
+{
+    m_windowIsKey = isKey;
+}
+
 void PlatformWebView::resizeTo(unsigned width, unsigned height)
 {
     WKRect frame = windowFrame();