Title: [211207] trunk
Revision
211207
Author
pvol...@apple.com
Date
2017-01-26 02:09:07 -0800 (Thu, 26 Jan 2017)

Log Message

Crash when setting custom scale factor.
https://bugs.webkit.org/show_bug.cgi?id=167369

Reviewed by Sam Weinig.

Source/WebKit/mac:

Add null pointer check.

* WebView/WebView.mm:
(-[WebView _setCustomBackingScaleFactor:]):

Source/WebKit/win:

Add null pointer check.

* WebView.cpp:
(WebView::setCustomBackingScaleFactor):

Tools:

Added API test.

* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/Tests/WebKit/win/ScaleWebView.cpp: Added.
(TestWebKitAPI::WebKitCreateInstance):
(TestWebKitAPI::ScaleWebView::SetUp):
(TestWebKitAPI::ScaleWebView::TearDown):
(TestWebKitAPI::TEST_F):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (211206 => 211207)


--- trunk/Source/WebKit/mac/ChangeLog	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-01-26 10:09:07 UTC (rev 211207)
@@ -1,3 +1,15 @@
+2017-01-26  Per Arne Vollan  <pvol...@apple.com>
+
+        Crash when setting custom scale factor.
+        https://bugs.webkit.org/show_bug.cgi?id=167369
+
+        Reviewed by Sam Weinig.
+
+        Add null pointer check.
+
+        * WebView/WebView.mm:
+        (-[WebView _setCustomBackingScaleFactor:]):
+
 2017-01-25  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Refactor drag and drop implementation on Mac

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (211206 => 211207)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-01-26 10:09:07 UTC (rev 211207)
@@ -4941,7 +4941,7 @@
 
     _private->customDeviceScaleFactor = customScaleFactor;
 
-    if (oldScaleFactor != [self _deviceScaleFactor])
+    if (_private->page && oldScaleFactor != [self _deviceScaleFactor])
         _private->page->setDeviceScaleFactor([self _deviceScaleFactor]);
 }
 #endif

Modified: trunk/Source/WebKit/win/ChangeLog (211206 => 211207)


--- trunk/Source/WebKit/win/ChangeLog	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Source/WebKit/win/ChangeLog	2017-01-26 10:09:07 UTC (rev 211207)
@@ -1,3 +1,15 @@
+2017-01-26  Per Arne Vollan  <pvol...@apple.com>
+
+        Crash when setting custom scale factor.
+        https://bugs.webkit.org/show_bug.cgi?id=167369
+
+        Reviewed by Sam Weinig.
+
+        Add null pointer check.
+
+        * WebView.cpp:
+        (WebView::setCustomBackingScaleFactor):
+
 2017-01-24  Youenn Fablet  <youe...@gmail.com>
 
         [WebRTC] Introduce libwebrtc abstraction for WK1/WK2 implementations

Modified: trunk/Source/WebKit/win/WebView.cpp (211206 => 211207)


--- trunk/Source/WebKit/win/WebView.cpp	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Source/WebKit/win/WebView.cpp	2017-01-26 10:09:07 UTC (rev 211207)
@@ -7757,7 +7757,7 @@
 
     m_customDeviceScaleFactor = customScaleFactor;
 
-    if (oldScaleFactor != deviceScaleFactor())
+    if (m_page && oldScaleFactor != deviceScaleFactor())
         m_page->setDeviceScaleFactor(deviceScaleFactor());
 
     return S_OK;

Modified: trunk/Tools/ChangeLog (211206 => 211207)


--- trunk/Tools/ChangeLog	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Tools/ChangeLog	2017-01-26 10:09:07 UTC (rev 211207)
@@ -1,3 +1,19 @@
+2017-01-26  Per Arne Vollan  <pvol...@apple.com>
+
+        Crash when setting custom scale factor.
+        https://bugs.webkit.org/show_bug.cgi?id=167369
+
+        Reviewed by Sam Weinig.
+
+        Added API test.
+
+        * TestWebKitAPI/PlatformWin.cmake:
+        * TestWebKitAPI/Tests/WebKit/win/ScaleWebView.cpp: Added.
+        (TestWebKitAPI::WebKitCreateInstance):
+        (TestWebKitAPI::ScaleWebView::SetUp):
+        (TestWebKitAPI::ScaleWebView::TearDown):
+        (TestWebKitAPI::TEST_F):
+
 2017-01-25  Ryosuke Niwa  <rn...@webkit.org>
 
         run-benchmark nests MotionMark results by the suite name twice

Modified: trunk/Tools/TestWebKitAPI/PlatformWin.cmake (211206 => 211207)


--- trunk/Tools/TestWebKitAPI/PlatformWin.cmake	2017-01-26 09:21:46 UTC (rev 211206)
+++ trunk/Tools/TestWebKitAPI/PlatformWin.cmake	2017-01-26 10:09:07 UTC (rev 211207)
@@ -142,6 +142,7 @@
 add_library(TestWebKitLib SHARED
     ${test_main_SOURCES}
     ${TESTWEBKITAPI_DIR}/TestsController.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit/win/ScaleWebView.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit/win/WebViewDestruction.cpp
     ${TESTWEBKITAPI_DIR}/win/HostWindow.cpp
 )

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/win/ScaleWebView.cpp (0 => 211207)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/win/ScaleWebView.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/win/ScaleWebView.cpp	2017-01-26 10:09:07 UTC (rev 211207)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
+ */
+
+#include "config.h"
+
+#include "HostWindow.h"
+#include "Test.h"
+#include <WebCore/COMPtr.h>
+#include <WebKit/WebKit.h>
+#include <WebKit/WebKitCOMAPI.h>
+
+namespace TestWebKitAPI {
+
+template <typename T>
+static HRESULT WebKitCreateInstance(REFCLSID clsid, T** object)
+{
+    return WebKitCreateInstance(clsid, 0, __uuidof(T), reinterpret_cast<void**>(object));
+}
+
+class ScaleWebView : public ::testing::Test {
+protected:
+    virtual void SetUp();
+    virtual void TearDown();
+
+    COMPtr<IWebView> m_webView;
+    HostWindow m_window;
+};
+
+void ScaleWebView::SetUp()
+{
+    EXPECT_HRESULT_SUCCEEDED(WebKitCreateInstance(__uuidof(WebView), &m_webView));
+    EXPECT_TRUE(m_window.initialize());
+    EXPECT_HRESULT_SUCCEEDED(m_webView->setHostWindow(m_window.window()));
+}
+
+void ScaleWebView::TearDown()
+{
+    m_webView = 0;
+}
+
+// Tests that scaling a WebView before calling IWebView::initWithFrame doesn't crash.
+TEST_F(ScaleWebView, ScaleBeforeInitWithFrame)
+{
+    COMPtr<IWebViewPrivate2> viewPrivate(Query, m_webView);
+    ASSERT_NOT_NULL(viewPrivate);
+    EXPECT_HRESULT_SUCCEEDED(viewPrivate->setCustomBackingScaleFactor(2));
+    EXPECT_HRESULT_SUCCEEDED(m_webView->initWithFrame(m_window.clientRect(), 0, 0));
+}
+
+} // namespace WebKitAPITest
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to