Regression(r203623): Breaks App Store application
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2016 21:48:33 +0000 (21:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2016 21:48:33 +0000 (21:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161206
<rdar://problem/28015060>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Add quirks for the App Store application so that we log an error message
when passing a Document node to Window.getComputedStyle() instead of
throwing an exception.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::getComputedStyle):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* platform/RuntimeApplicationChecks.h:
* platform/RuntimeApplicationChecks.mm:
(WebCore::MacApplication::isAppStore):

LayoutTests:

Rebaseline existing test as the exception message is slightly different.

* fast/dom/Window/getComputedStyle-missing-parameter-expected.txt:
* fast/dom/Window/getComputedStyle-missing-parameter.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/getComputedStyle-missing-parameter-expected.txt
LayoutTests/fast/dom/Window/getComputedStyle-missing-parameter.html
Source/WebCore/ChangeLog
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindow.idl
Source/WebCore/platform/RuntimeApplicationChecks.h
Source/WebCore/platform/RuntimeApplicationChecks.mm

index 73f4259..5909fbb 100644 (file)
@@ -1,3 +1,16 @@
+2016-08-25  Chris Dumez  <cdumez@apple.com>
+
+        Regression(r203623): Breaks App Store application
+        https://bugs.webkit.org/show_bug.cgi?id=161206
+        <rdar://problem/28015060>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline existing test as the exception message is slightly different.
+
+        * fast/dom/Window/getComputedStyle-missing-parameter-expected.txt:
+        * fast/dom/Window/getComputedStyle-missing-parameter.html:
+
 2016-08-25  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, rebase iOS simulator WK1 fast/css tests
index c8a9f0c..53e4a5c 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS window.getComputedStyle() threw exception TypeError: Not enough arguments.
-PASS window.getComputedStyle(null) threw exception TypeError: Argument 1 ('element') to Window.getComputedStyle must be an instance of Element.
+PASS window.getComputedStyle(null) threw exception TypeError: Type error.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 7ac0bfe..c8d2967 100644 (file)
@@ -5,8 +5,8 @@
 <script>
 description("Test that the first parameter to Window.getComputedStyle() is mandatory and not nullable.");
 
-shouldThrow("window.getComputedStyle()", "'TypeError: Not enough arguments'");
-shouldThrow("window.getComputedStyle(null)", "'TypeError: Argument 1 (\\'element\\') to Window.getComputedStyle must be an instance of Element'");
+shouldThrowErrorName("window.getComputedStyle()", "TypeError");
+shouldThrowErrorName("window.getComputedStyle(null)", "TypeError");
 </script>
 <script src="../../../resources/js-test-post.js"></script>
 </body>
index 180c899..68e17e9 100644 (file)
@@ -1,3 +1,23 @@
+2016-08-25  Chris Dumez  <cdumez@apple.com>
+
+        Regression(r203623): Breaks App Store application
+        https://bugs.webkit.org/show_bug.cgi?id=161206
+        <rdar://problem/28015060>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add quirks for the App Store application so that we log an error message
+        when passing a Document node to Window.getComputedStyle() instead of
+        throwing an exception.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::getComputedStyle):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * platform/RuntimeApplicationChecks.h:
+        * platform/RuntimeApplicationChecks.mm:
+        (WebCore::MacApplication::isAppStore):
+
 2016-08-25  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         REGRESSION (r203378): [iOS] The PDF image is rendered stretched if a sub image of it is cached first
index 84c8105..ca7956d 100644 (file)
@@ -81,6 +81,7 @@
 #include "PageTransitionEvent.h"
 #include "Performance.h"
 #include "ResourceLoadInfo.h"
+#include "RuntimeApplicationChecks.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScheduledAction.h"
 #include "Screen.h"
@@ -1405,6 +1406,19 @@ RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Element& element, const
     return CSSComputedStyleDeclaration::create(element, false, pseudoElt);
 }
 
+// FIXME: Drop this overload once <rdar://problem/28016778> has been fixed.
+RefPtr<CSSStyleDeclaration> DOMWindow::getComputedStyle(Document&, const String&, ExceptionCode& ec)
+{
+#if PLATFORM(MAC)
+    if (MacApplication::isAppStore()) {
+        printErrorMessage(ASCIILiteral("Passing a non-Element as first parameter to window.getComputedStyle() is invalid and always returns null"));
+        return nullptr;
+    }
+#endif
+    ec = TypeError;
+    return nullptr;
+}
+
 RefPtr<CSSRuleList> DOMWindow::getMatchedCSSRules(Element* element, const String& pseudoElement, bool authorOnly) const
 {
     if (!isCurrentlyDisplayedInFrame())
index ba2c9d1..5bda953 100644 (file)
@@ -229,6 +229,7 @@ namespace WebCore {
         // DOM Level 2 Style Interface
 
         WEBCORE_EXPORT RefPtr<CSSStyleDeclaration> getComputedStyle(Element&, const String& pseudoElt) const;
+        RefPtr<CSSStyleDeclaration> getComputedStyle(Document&, const String& pseudoElt, ExceptionCode&);
 
         // WebKit extensions
 
index 3359a4c..28f2da3 100644 (file)
 
     // DOM Level 2 Style Interface
     [NewObject] CSSStyleDeclaration getComputedStyle(Element element, optional DOMString? pseudoElement = null);
+    // FIXME: Drop this overload once <rdar://problem/28016778> has been fixed.
+    [NewObject, RaisesException] CSSStyleDeclaration getComputedStyle(Document document, optional DOMString? pseudoElement = null);
 
     // WebKit extensions
 #if !(defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT)
index 3485431..8cad82c 100644 (file)
@@ -51,6 +51,7 @@ WEBCORE_EXPORT bool isSafari();
 bool isSolidStateNetworksDownloader();
 WEBCORE_EXPORT bool isVersions();
 WEBCORE_EXPORT bool isHRBlock();
+WEBCORE_EXPORT bool isAppStore();
 
 } // MacApplication
 
index aa17b66..8d4722c 100644 (file)
@@ -154,6 +154,12 @@ bool MacApplication::isSolidStateNetworksDownloader()
     return isSolidStateNetworksDownloader;
 }
 
+bool MacApplication::isAppStore()
+{
+    static bool isAppStore = applicationBundleIsEqualTo("com.apple.appstore");
+    return isAppStore;
+}
+
 #endif // PLATFORM(MAC)
 
 #if PLATFORM(IOS)