LayoutTests:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2006 23:54:29 +0000 (23:54 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2006 23:54:29 +0000 (23:54 +0000)
        Reviewed by Darin Adler.

        Removed Dashboard quirk from expected results. Now that we have a Dashboard
        quirks mode, there's no reason to keep the old, bad behavior in the browser.

        * http/tests/xmlhttprequest/exceptions-expected.txt:
        * http/tests/xmlhttprequest/exceptions.html:

WebCore:

        Reviewed by Darin Adler.

        Added support for Dashboard backward compatibility mode.

        * html/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::stroke): Added support for old behavior
        of automatically clearing the stroke path buffer after a call to stroke().
        * html/HTMLCanvasElement.cpp: Added supoprt for old behavior of the canvas
        tag being self-closing.
        (WebCore::HTMLCanvasElement::endTagRequirement):
        (WebCore::HTMLCanvasElement::tagPriority):
        * html/HTMLCanvasElement.h:
        * html/HTMLParser.cpp: Ditto.
        (WebCore::HTMLParser::canvasCreateErrorCheck):
        * xml/xmlhttprequest.cpp: Added support for old behavior of silently ignoring
        a call to setRequestHeader() if it preceded a call to open() or followed a call
        to send().
        (WebCore::XMLHttpRequest::setRequestHeader):

WebKit:

        Reviewed by Darin Adler.

        Added SPI for enabling Dashboard backward compatibility mode. For now,
        we enable it unconditionally for Dashboard and Dashcode. Once they
        implement specific support for the backward compatibility mode behavior,
        we can change that.

        Set the default WebDashboardBehaviorUseBackwardCompatibilityModeEnabled
        to YES in order to turn this code on.

        * WebView/WebView.mm:
        (-[WebView _setDashboardBehavior:to:]):
        (-[WebView _dashboardBehavior:]):
        * WebView/WebViewPrivate.h:

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/exceptions-expected.txt
LayoutTests/http/tests/xmlhttprequest/exceptions.html
WebCore/ChangeLog
WebCore/bridge/mac/WebCoreSettings.h
WebCore/bridge/mac/WebCoreSettings.mm
WebCore/html/CanvasRenderingContext2D.cpp
WebCore/html/HTMLCanvasElement.cpp
WebCore/html/HTMLCanvasElement.h
WebCore/html/HTMLParser.cpp
WebCore/page/Settings.h
WebCore/xml/xmlhttprequest.cpp
WebKit/ChangeLog
WebKit/WebView/WebView.mm
WebKit/WebView/WebViewPrivate.h

index 4093114f8e7f6be971c38e1d305286a8e7386b73..75e56cbaabd3e9b161c3b21f01fa4e11f142d34e 100644 (file)
@@ -1,3 +1,13 @@
+2006-12-02  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin Adler.
+        
+        Removed Dashboard quirk from expected results. Now that we have a Dashboard
+        quirks mode, there's no reason to keep the old, bad behavior in the browser.
+
+        * http/tests/xmlhttprequest/exceptions-expected.txt:
+        * http/tests/xmlhttprequest/exceptions.html:
+
 2006-12-04  Rob Buis  <buis@kde.org>
 
         Reviewed by dhyatt.
index 2648593bc08f5e4bd7b3e3e42a4f0080eb41d52b..ad64cb232d8139da4f63edfa1cc1a1bae859ee59 100644 (file)
@@ -1,6 +1,7 @@
 Test that XMLHttpRequest raises exceptions when it should.
 
 new XMLHttpRequest()
+PASS: req.setRequestHeader("Foo", "bar") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.send(null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.open("GET", "http://www.apple.com/", true) threw exception Error: Permission denied.
 open()
@@ -10,5 +11,6 @@ PASS: req.status() threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.statusText() threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 send()
 PASS: req.send(null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS: req.setRequestHeader("Foo", "bar") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 PASS: req.getResponseHeader() threw exception SyntaxError: Not enough arguments.
 
index c1eb7948729cebec9e2d5ab774472c96690fc14c..097cac50fedafba85f6c9399b5f2e1b1e1700d1d 100644 (file)
     }
     log("new XMLHttpRequest()");
 
-    // According to the XHR spec, this should throw INVALID_STATE_ERR. However,
-    // widgets exist that depend on WebKit not throwing an exception here, and
-    // to make them keep working we have to go against spec and support this
-    // legacy behavior. See <rdar://problem/4758577> "REGRESSION: Business and
-    // People widgets fails to complete search query" for more details.
-    req.setRequestHeader("Foo", "bar");
-
+    shouldThrow('req.setRequestHeader("Foo", "bar")');
     shouldThrow('req.send(null)');
-
     shouldThrow('req.open("GET", "http://www.apple.com/", true)');
     
     req.open('GET', 'resources/zero-length.txt', false);
     log("send()");
 
     shouldThrow('req.send(null)');
-
-    // According to the XHR spec, this should throw INVALID_STATE_ERR. However,
-    // widgets exist that depend on WebKit not throwing an exception here, and
-    // to make them keep working we have to go against spec and support this
-    // legacy behavior. See <rdar://problem/4758577> "REGRESSION: Business and
-    // People widgets fails to complete search query" for more details.
-    req.setRequestHeader("Foo", "bar");
-
+    shouldThrow('req.setRequestHeader("Foo", "bar")');
     shouldThrow('req.getResponseHeader()');
    
 </script>
index 3dc9b6f6c8853d60fc06ea521a74b3c2e104fd3f..10e85390985435dbbb8c22379c47749a9915c8a7 100644 (file)
@@ -1,3 +1,24 @@
+2006-12-02  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin Adler.
+        
+        Added support for Dashboard backward compatibility mode.
+        
+        * html/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::stroke): Added support for old behavior
+        of automatically clearing the stroke path buffer after a call to stroke().
+        * html/HTMLCanvasElement.cpp: Added supoprt for old behavior of the canvas
+        tag being self-closing.
+        (WebCore::HTMLCanvasElement::endTagRequirement):
+        (WebCore::HTMLCanvasElement::tagPriority):
+        * html/HTMLCanvasElement.h:
+        * html/HTMLParser.cpp: Ditto.
+        (WebCore::HTMLParser::canvasCreateErrorCheck):
+        * xml/xmlhttprequest.cpp: Added support for old behavior of silently ignoring
+        a call to setRequestHeader() if it preceded a call to open() or followed a call
+        to send().
+        (WebCore::XMLHttpRequest::setRequestHeader):
+
 2006-12-04  Darin Adler  <darin@apple.com>
 
         Reviewed by Alice.
index ff2b6f4b51deb99fba7019014ab27cb16e70aeec..051fc8283d87a0212a31990a2925759162edf8b0 100644 (file)
@@ -121,6 +121,9 @@ typedef WebCore::Settings WebCoreSettingsImpl;
 - (void)setEditableLinkBehavior:(int)behavior;
 - (int)editableLinkBehavior;
 
+- (void)setShouldUseDashboardBackwardCompatibilityMode:(BOOL)use;
+- (BOOL)shouldUseDashboardBackwardCompatibilityMode;
+
 - (WebCoreSettingsImpl *)settings;
 
 @end
index cd3461a4ca8d5a393b02df98582ac1eb27d1d5a2..f29d3b044a70f731377e5a095352353fe422a843 100644 (file)
@@ -351,6 +351,16 @@ using namespace WebCore;
     return (int)settings->editableLinkBehavior();
 }
 
+- (void)setShouldUseDashboardBackwardCompatibilityMode:(BOOL)use
+{
+    settings->setShouldUseDashboardBackwardCompatibilityMode(use);
+}
+
+- (BOOL)shouldUseDashboardBackwardCompatibilityMode;
+{
+    return settings->shouldUseDashboardBackwardCompatibilityMode();
+}
+
 - (Settings *)settings
 {
     return settings;
index cb684cc775587b8428b79e9b5cb6dce9a93afb1a..cd3e909a2a98f45be75a0d541a5da74a9dc46415 100644 (file)
 #include "config.h"
 #include "CanvasRenderingContext2D.h"
 
+#include "AffineTransform.h"
 #include "CachedImage.h"
 #include "CanvasGradient.h"
 #include "CanvasPattern.h"
 #include "CanvasStyle.h"
+#include "Document.h"
 #include "ExceptionCode.h"
+#include "Frame.h"
 #include "GraphicsContext.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "RenderHTMLCanvas.h"
+#include "Settings.h"
 #include "cssparser.h"
-#include "AffineTransform.h"
 #include <wtf/MathExtras.h>
 
 namespace WebCore {
@@ -474,6 +477,9 @@ void CanvasRenderingContext2D::stroke()
         CGContextStrokePath(c->platformContext());
     }
 #endif
+
+    if (m_canvas && m_canvas->document()->frame() && m_canvas->document()->frame()->settings()->shouldUseDashboardBackwardCompatibilityMode())
+        state().m_path.clear();
 }
 
 void CanvasRenderingContext2D::clip()
index 6472d0e98fa00436f45b9d8628b88846d3c07a60..1823e08a1786797bb637b1f249677e3dac3da316 100644 (file)
@@ -37,6 +37,7 @@
 #include "Page.h"
 #include "RenderHTMLCanvas.h"
 #include "Chrome.h"
+#include "Settings.h"
 #include "Screen.h"
 #include <math.h>
 
@@ -44,7 +45,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-// These value come from the specification.
+// These values come from the WhatWG spec.
 const int defaultWidth = 300;
 const int defaultHeight = 150;
 
@@ -65,6 +66,22 @@ HTMLCanvasElement::~HTMLCanvasElement()
     delete m_drawingContext;
 }
 
+HTMLTagStatus HTMLCanvasElement::endTagRequirement() const 
+{ 
+    if (document()->frame() && document()->frame()->settings()->shouldUseDashboardBackwardCompatibilityMode())
+        return TagStatusForbidden; 
+
+    return HTMLElement::endTagRequirement();
+}
+
+int HTMLCanvasElement::tagPriority() const 
+{ 
+    if (document()->frame() && document()->frame()->settings()->shouldUseDashboardBackwardCompatibilityMode())
+        return 0; 
+
+    return HTMLElement::tagPriority();
+}
+
 void HTMLCanvasElement::parseMappedAttribute(MappedAttribute* attr)
 {
     const QualifiedName& attrName = attr->name();
index 4acabe740f0aca9cdc1d547e9638453ec56106ce..846d362aa7925a08432dbe339ddc3045b8217381 100644 (file)
@@ -47,6 +47,9 @@ public:
     HTMLCanvasElement(Document*);
     virtual ~HTMLCanvasElement();
 
+    virtual HTMLTagStatus endTagRequirement() const;
+    virtual int tagPriority() const;
+
     int width() const { return m_size.width(); }
     int height() const { return m_size.height(); }
     void setWidth(int);
index 415e0a7e26939dbb4fb14e567a1efb3acfda6dcd..6981bc54c337b16ab74131e8aed4575fa8428bd9 100644 (file)
@@ -48,6 +48,7 @@
 #include "HTMLTableSectionElement.h"
 #include "HTMLTokenizer.h"
 #include "LocalizedStrings.h"
+#include "Settings.h"
 #include "Text.h"
 
 namespace WebCore {
@@ -763,6 +764,9 @@ bool HTMLParser::mapCreateErrorCheck(Token* t, RefPtr<Node>& result)
 
 bool HTMLParser::canvasCreateErrorCheck(Token* t, RefPtr<Node>& result)
 {
+    if (document->frame() && document->frame()->settings()->shouldUseDashboardBackwardCompatibilityMode())
+        return true;
+
     if (!m_fragment && document->frame() && document->frame()->javaScriptEnabled())
         setSkipMode(canvasTag);
     return true;
index 740892fe751ad0b157dca5d98f4a4d887181c68f..3c56679f75ad9f91ba552328a6ce6066faaca161 100644 (file)
@@ -54,8 +54,9 @@ public:
         , m_pluginsEnabled(0)
         , m_javaScriptEnabled(0)
         , m_javaScriptCanOpenWindowsAutomatically(0)
-        , m_shouldPrintBackgrounds(0)
+        , m_shouldPrintBackgrounds(false)
         , m_textAreasAreResizable(0)
+        , m_shouldUseDashboardBackwardCompatibilityMode(false)
         , m_editableLinkBehavior(EditableLinkDefaultBehavior)
     {
     }
@@ -113,6 +114,9 @@ public:
     void setTextAreasAreResizable(bool f) { m_textAreasAreResizable = f; }
     void setEditableLinkBehavior(EditableLinkBehavior e) { m_editableLinkBehavior = e; }
     
+    void setShouldUseDashboardBackwardCompatibilityMode(bool b) { m_shouldUseDashboardBackwardCompatibilityMode = b; }
+    bool shouldUseDashboardBackwardCompatibilityMode() const { return m_shouldUseDashboardBackwardCompatibilityMode; }
+    
 private:
     AtomicString m_stdFontName;
     AtomicString m_fixedFontName;
@@ -135,6 +139,7 @@ private:
     bool m_javaScriptCanOpenWindowsAutomatically : 1;
     bool m_shouldPrintBackgrounds : 1;
     bool m_textAreasAreResizable : 1;
+    bool m_shouldUseDashboardBackwardCompatibilityMode : 1;
     EditableLinkBehavior m_editableLinkBehavior;
 };
 
index 3c4766493a2ba1ac12c97e2f711b23261bb3044c..f7ee4a9b3938db82a18f212333325ba95767c8eb 100644 (file)
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FormData.h"
+#include "Frame.h"
 #include "HTMLDocument.h"
 #include "LoaderFunctions.h"
 #include "PlatformString.h"
 #include "RegularExpression.h"
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
+#include "Settings.h"
 #include "TextEncoding.h"
 #include "kjs_binding.h"
 #include <kjs/protect.h>
@@ -384,9 +386,13 @@ void XMLHttpRequest::overrideMIMEType(const String& override)
 
 void XMLHttpRequest::setRequestHeader(const String& name, const String& value, ExceptionCode& ec)
 {
-    if (m_state != Open)
-        // rdar 4758577: XHR spec says an exception should be thrown here.  However, doing so breaks the Business and People widgets.
+    if (m_state != Open) {
+        if (m_doc && m_doc->frame() && m_doc->frame()->settings()->shouldUseDashboardBackwardCompatibilityMode())
+            return;
+
+        ec = INVALID_STATE_ERR;
         return;
+    }
 
     if (!m_requestHeaders.contains(name)) {
         m_requestHeaders.set(name, value);
index 009ef56b02721a8a6c32dabf033855aafb693874..3d71fe017fd8c8194572cb20e68156145fc2ccaf 100644 (file)
@@ -1,3 +1,20 @@
+2006-12-02  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin Adler.
+        
+        Added SPI for enabling Dashboard backward compatibility mode. For now,
+        we enable it unconditionally for Dashboard and Dashcode. Once they 
+        implement specific support for the backward compatibility mode behavior,
+        we can change that.
+        
+        Set the default WebDashboardBehaviorUseBackwardCompatibilityModeEnabled
+        to YES in order to turn this code on.
+
+        * WebView/WebView.mm:
+        (-[WebView _setDashboardBehavior:to:]):
+        (-[WebView _dashboardBehavior:]):
+        * WebView/WebViewPrivate.h:
+
 2006-12-04  Darin Adler  <darin@apple.com>
 
         Reviewed by Alice.
index 611018712b8af79da20892d8cd25392fb19cda0f..25401f91944af4c479238c8d77c1c84c64b8f660 100644 (file)
@@ -1443,8 +1443,17 @@ WebResourceDelegateImplementationCache WebViewGetResourceLoadDelegateImplementat
     return regions;
 }
 
-- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag;
+- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag
 {
+    // FIXME: Remove this defaults read once we decide to "turn on" compatibility
+    // mode support for good.
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"WebDashboardBehaviorUseBackwardCompatibilityModeEnabled"]) {
+        // FIXME: Remove this blanket assignment once Dashboard and Dashcode implement 
+        // specific support for the backward compatibility mode flag.
+        if (behavior == WebDashboardBehaviorAllowWheelScrolling && flag == NO)
+            [_private->settings setShouldUseDashboardBackwardCompatibilityMode:YES];
+    }
+    
     switch (behavior) {
         case WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows: {
             _private->dashboardBehaviorAlwaysSendMouseEventsToAllWindows = flag;
@@ -1462,6 +1471,10 @@ WebResourceDelegateImplementationCache WebViewGetResourceLoadDelegateImplementat
             _private->dashboardBehaviorAllowWheelScrolling = flag;
             break;
         }
+        case WebDashboardBehaviorUseBackwardCompatibilityMode: {
+            [_private->settings setShouldUseDashboardBackwardCompatibilityMode:flag];
+            break;
+        }
     }
 }
 
@@ -1480,6 +1493,9 @@ WebResourceDelegateImplementationCache WebViewGetResourceLoadDelegateImplementat
         case WebDashboardBehaviorAllowWheelScrolling: {
             return _private->dashboardBehaviorAllowWheelScrolling;
         }
+        case WebDashboardBehaviorUseBackwardCompatibilityMode: {
+            return [_private->settings shouldUseDashboardBackwardCompatibilityMode];
+        }
     }
     return NO;
 }
index 2f0afc790fba4d39b4ae0cfcc318125459cc7283..f93606c4f0382f8b5b905366070a5789f69e8769 100644 (file)
@@ -92,7 +92,8 @@ typedef enum {
     WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
     WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,
     WebDashboardBehaviorAlwaysAcceptsFirstMouse,
-    WebDashboardBehaviorAllowWheelScrolling
+    WebDashboardBehaviorAllowWheelScrolling,
+    WebDashboardBehaviorUseBackwardCompatibilityMode
 } WebDashboardBehavior;
 
 @interface WebController : NSTreeController {