2007-05-11 Oliver Hunt <oliver@apple.com>
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2007 21:54:12 +0000 (21:54 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2007 21:54:12 +0000 (21:54 +0000)
LayoutTests:

        Reviewed by Brady.

        Layout tests for <rdar://problem/5017375> WebKit should disable SVG in Dashboard
        Tests attempt to use SVG in a number of ways, both direct and indirect.

        * http/tests/xmlhttprequest/resources/svgtest.svg: Added.
          Small test SVG

        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard-expected.txt: Added.
        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html: Added.
          Attempts to use an SVG doc created with XHR as content

        * svg/custom/embedded-svg-disallowed-in-dashboard-expected.txt: Added.
        * svg/custom/embedded-svg-disallowed-in-dashboard.xml: Added.
          Attempts to use SVG by embedding it in an SVG doc.

        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard-expected.txt: Added.
        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html: Added.
          Attempts to use SVG by using a DOMParser to manually parse XHMTL with embedded SVG

        * svg/custom/manually-parsed-svg-disallowed-in-dashboard-expected.txt: Added.
        * svg/custom/manually-parsed-svg-disallowed-in-dashboard.html: Added.
          Attempts to use SVG by using a DOMParser to manually create an SVG doc from a string

        * svg/custom/svg-disallowed-in-dashboard-object-expected.txt: Added.
        * svg/custom/svg-disallowed-in-dashboard-object.html: Added.
          Attempts to embed SVG with <embed>, <object>, and <iframe>

WebCore:

        Reviewed by Brady.

        <rdar://problem/5017375> WebKit should disable SVG in Dashboard

        Prevents an SVG document or element from being created when in
        dashboard compatibility mode.

        Manually parsing, or using XHR to created a document removes our
        ability to detect Dashboard compatibility mode, so we also perform
        the check when importing nodes from one document into another.

        * dom/DOMImplementation.cpp:
        (WebCore::DOMImplementation::createDocument):
          Don't create an SVGDocument if we're in dashboard compatibility mode

        * dom/Document.cpp:
        (WebCore::Document::importNode):
          Don't import SVG nodes if we're in dashboard compatibility mode

        * ksvg2/scripts/make_names.pl:
          Don't create SVG elements for documents that are in dashboard
          compatibility mode

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/resources/svgtest.svg [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html [new file with mode: 0644]
LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard.xml [new file with mode: 0644]
LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html [new file with mode: 0644]
LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard.html [new file with mode: 0644]
LayoutTests/svg/custom/svg-disallowed-in-dashboard-object-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/svg-disallowed-in-dashboard-object.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/DOMImplementation.cpp
WebCore/dom/Document.cpp
WebCore/ksvg2/scripts/make_names.pl

index 7a59c7ab696199cad0d96fd4cde3cf124a5f2aa1..f564a1e4d7de37f806b4119156d357a93d62593c 100644 (file)
@@ -1,3 +1,34 @@
+2007-05-11  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Brady.
+
+        Layout tests for <rdar://problem/5017375> WebKit should disable SVG in Dashboard
+        Tests attempt to use SVG in a number of ways, both direct and indirect.
+        
+
+        * http/tests/xmlhttprequest/resources/svgtest.svg: Added.
+          Small test SVG
+          
+        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard-expected.txt: Added.
+        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html: Added.
+          Attempts to use an SVG doc created with XHR as content 
+        
+        * svg/custom/embedded-svg-disallowed-in-dashboard-expected.txt: Added.
+        * svg/custom/embedded-svg-disallowed-in-dashboard.xml: Added.
+          Attempts to use SVG by embedding it in an SVG doc.
+        
+        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard-expected.txt: Added.
+        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html: Added.
+          Attempts to use SVG by using a DOMParser to manually parse XHMTL with embedded SVG
+        
+        * svg/custom/manually-parsed-svg-disallowed-in-dashboard-expected.txt: Added.
+        * svg/custom/manually-parsed-svg-disallowed-in-dashboard.html: Added.
+          Attempts to use SVG by using a DOMParser to manually create an SVG doc from a string
+        
+        * svg/custom/svg-disallowed-in-dashboard-object-expected.txt: Added.
+        * svg/custom/svg-disallowed-in-dashboard-object.html: Added.
+          Attempts to embed SVG with <embed>, <object>, and <iframe>
+
 2007-05-11  Mark Rowe  <mrowe@apple.com>
 
         Rubber-stamped by Oliver.
diff --git a/LayoutTests/http/tests/xmlhttprequest/resources/svgtest.svg b/LayoutTests/http/tests/xmlhttprequest/resources/svgtest.svg
new file mode 100644 (file)
index 0000000..b12176f
--- /dev/null
@@ -0,0 +1,4 @@
+<!-- Small test SVG for http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html test -->
+<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+    <circle id="svgCircle" cx="50" cy="50" r="50" fill="red"/>
+</svg>
diff --git a/LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard-expected.txt b/LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard-expected.txt
new file mode 100644 (file)
index 0000000..6aa50b8
--- /dev/null
@@ -0,0 +1,6 @@
+Test to make sure we can't use XHR to create usable SVG in dashboard compatibility mode. This cannot be tested manually.
+
+Received doc of type: [object Document]
+Contained circle element is of type: [object SVGCircleElement]
+PASS: Could not insert SVG element into tree
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html b/LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html
new file mode 100644 (file)
index 0000000..ec876a8
--- /dev/null
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Test to ensure SVG is disabled in Dashboard compatibility mode</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<script language="JavaScript" type="text/JavaScript">
+
+    var rq;
+
+    function loadSVG()
+    {
+        url = 'resources/svgtest.svg';
+
+        rq = false;
+    
+        try {
+          if (window.XMLHttpRequest) {
+            rq = new XMLHttpRequest();
+            rq.overrideMimeType('text/svg+xml');
+            rq.onreadystatechange = processReqChange;
+            rq.open('GET', url, true);
+            rq.send();
+          }
+        } catch (ex) {
+            rq = false;
+            alert(ex);
+        }
+    }
+    
+    function debug(str) {
+        var c = document.getElementById('console')
+        c.appendChild(document.createTextNode(str + '\n'));
+    }
+
+    function processReqChange()
+    {
+        if (rq.readyState == 4) {
+            try {
+                var svgDoc = rq.responseXML;
+                if (rq.status == 200) {
+                    debug("Received doc of type: " + svgDoc);
+                    debug("Contained circle element is of type: " + svgDoc.getElementById('svgCircle'));
+                    // Import SVG element into tree.
+                    var importedNode = null;
+                    try {
+                        importedNode = document.importNode(svgDoc.getElementById('svgCircle'), true);
+                    } catch(e) {
+                    }
+            
+                    if (importedNode) {
+                        debug("FAIL: Managed to insert SVG element into tree");
+                        debug("Imported node of type: " + importedNode);
+                        document.getElementById('targetDiv').appendChild(importedNode);
+                    } else {
+                        debug("PASS: Could not insert SVG element into tree");
+                    }
+                } else {
+                    debug('FAIL: Unable to load SVG document: ' + rq.statusText);
+                }
+            } catch (e) {
+            }
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    }
+</script>
+</head>
+
+<body onLoad="loadSVG();">
+<p>Test to make sure we can't use XHR to create usable SVG in dashboard compatibility mode.  This cannot be tested manually.</p>
+<div id="targetDiv"></div>
+<pre id="console"></pre>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.setUseDashboardCompatiblityMode(true);
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard-expected.txt b/LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard-expected.txt
new file mode 100644 (file)
index 0000000..7d3af57
--- /dev/null
@@ -0,0 +1,4 @@
+This test is to ensure SVG elements can't be created by being embedded in xml documents. It can not be tested manually.
+
+ PASS: SVG Elements could not be created
+
diff --git a/LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard.xml b/LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard.xml
new file mode 100644 (file)
index 0000000..3a68b9d
--- /dev/null
@@ -0,0 +1,28 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>Make sure embedded SVG is turned off in dashboard</title>
+    </head>
+    <script>
+         if (window.layoutTestController) {
+             layoutTestController.setUseDashboardCompatiblityMode(true);
+             layoutTestController.dumpAsText();
+         }
+         function debug(str) {
+             var c = document.getElementById('console')
+             c.appendChild(document.createTextNode(str + '\n'));
+         }
+    </script>
+    <body>
+        <p>This test is to ensure SVG elements can't be created by being embedded in xml documents.  It can not be tested manually.</p>
+        <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+             <circle id="svgCircleNode" cx="100" cy="100" r="50" fill="red"/>
+        </svg>
+        <pre id="console"></pre> 
+        <script>
+           if(document.getElementById('svgCircleNode'))
+               debug("FAIL: Successfully embedded SVG in document");
+           else
+               debug("PASS: SVG Elements could not be created");
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard-expected.txt b/LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard-expected.txt
new file mode 100644 (file)
index 0000000..336ce0d
--- /dev/null
@@ -0,0 +1,6 @@
+This test makes sure we can't add manually parsed SVG to the document when in dashboard compatibility mode. It can not be tested manually.
+
+Parsing of the document isn't prevented and produces a [object Document]
+The circle element is of type [object SVGCircleElement]
+PASS: Could not insert SVG element into tree
+
diff --git a/LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html b/LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html
new file mode 100644 (file)
index 0000000..2e06121
--- /dev/null
@@ -0,0 +1,49 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>Make sure embedded SVG is turned off in dashboard</title>
+    </head>
+    <script>
+        function debug(str) {
+            var c = document.getElementById('console')
+            c.appendChild(document.createTextNode(str + '\n'));
+        }
+        
+        if (window.layoutTestController) {
+            layoutTestController.setUseDashboardCompatiblityMode(true);
+            layoutTestController.dumpAsText();
+        }
+    </script>
+    <body>
+        <p>This test makes sure we can't add manually parsed SVG to the document when in dashboard compatibility mode.  It can not be tested manually.</p>
+        <div id="targetDiv"></div>
+        <pre id="console"></pre> 
+        <script>
+            var documentString = '<html xmlns="http://www.w3.org/1999/xhtml">' +
+                                 '<body>' +
+                                 '<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">' +
+                                 '<circle id="svgCircle" cx="50" cy="50" r="50" fill="red"/></svg>' +
+                                 '</body></html>'; 
+
+            // Use DOMParser interface to create a SVGDocument datastructure from SVG content string
+            var parser = new DOMParser();
+            var xhtmlDocument = parser.parseFromString(documentString, "application/xhtml+xml");
+         
+            debug("Parsing of the document isn't prevented and produces a " + xhtmlDocument);
+            debug("The circle element is of type " + xhtmlDocument.getElementById('svgCircle'));
+            
+            // Import SVG element into tree.
+            var importedNode = null;
+            try {
+                importedNode = document.importNode(xhtmlDocument.firstChild, true);
+            } catch(e) {
+            }
+            
+            if (importedNode) {
+                debug("FAIL: Managed to insert SVG element into tree");
+                document.getElementById('targetDiv').appendChild(importedNode);
+            } else {
+                debug("PASS: Could not insert SVG element into tree");
+            }
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard-expected.txt b/LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard-expected.txt
new file mode 100644 (file)
index 0000000..b7bdb4c
--- /dev/null
@@ -0,0 +1,5 @@
+This test makes sure we can't add manually parsed SVG to the document when in dashboard compatibility mode. It can not be tested manually.
+
+Parsing of the document isn't prevented and produces a [object SVGDocument]
+PASS: Could not insert SVG element into tree
+
diff --git a/LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard.html b/LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard.html
new file mode 100644 (file)
index 0000000..5aea37d
--- /dev/null
@@ -0,0 +1,45 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>Make sure embedded SVG is turned off in dashboard</title>
+    </head>
+    <script>
+        function debug(str) {
+            var c = document.getElementById('console')
+            c.appendChild(document.createTextNode(str + '\n'));
+        }
+        
+        if (window.layoutTestController) {
+            layoutTestController.setUseDashboardCompatiblityMode(true);
+            layoutTestController.dumpAsText();
+        }
+    </script>
+    <body>
+        <p>This test makes sure we can't add manually parsed SVG to the document when in dashboard compatibility mode.  It can not be tested manually.</p>
+        <div id="targetDiv"></div>
+        <pre id="console"></pre> 
+        <script>
+            var documentString = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">' +
+                                 '<circle cx="50" cy="50" r="50" fill="red"/></svg>';
+
+            // Use DOMParser interface to create a SVGDocument datastructure from SVG content string
+            var parser = new DOMParser();
+            var svgDocument = parser.parseFromString(documentString, "image/svg+xml");
+
+            debug("Parsing of the document isn't prevented and produces a " + svgDocument);
+            
+            // Import SVG element into tree.
+            var importedNode = null;
+            try {
+                importedNode = document.importNode(svgDocument.firstChild, true);
+            } catch(e) {
+            }
+            
+            if (importedNode) {
+                debug("FAIL: Managed to insert SVG element into tree");
+                document.getElementById('targetDiv').appendChild(importedNode);
+            } else {
+                debug("PASS: Could not insert SVG element into tree");
+            }
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/svg/custom/svg-disallowed-in-dashboard-object-expected.txt b/LayoutTests/svg/custom/svg-disallowed-in-dashboard-object-expected.txt
new file mode 100644 (file)
index 0000000..2089dc0
--- /dev/null
@@ -0,0 +1,8 @@
+This test makes sure we can't open SVG documents in Dashboard compatibility mode. It can not be tested manually.
+
+    
+PASS: Did not load SVG document in <object> tag
+PASS: Did not load SVG document in <element> tag
+PASS: Did not load SVG document in <iframe> tag
+PASS: SVG Documents were not loaded
+
diff --git a/LayoutTests/svg/custom/svg-disallowed-in-dashboard-object.html b/LayoutTests/svg/custom/svg-disallowed-in-dashboard-object.html
new file mode 100644 (file)
index 0000000..1f8acd0
--- /dev/null
@@ -0,0 +1,71 @@
+<html>
+<body>
+<p>This test makes sure we can't open SVG documents in Dashboard compatibility mode.  It can not be tested manually.</p>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.setUseDashboardCompatiblityMode(true);
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    function debug(str) {
+        var c = document.getElementById('console')
+        c.appendChild(document.createTextNode(str + '\n'));
+    }
+    
+    setTimeout("timeOut()", 500);
+    function timeOut() {
+        try {
+            var failed = false;
+            var svgDoc = null;
+            try {
+                svgDoc = document.getElementById('svgObject').getSVGDocument();
+            } catch (e) {
+                svgDoc = null;
+            }
+            if (svgDoc) {
+                debug("FAIL: Loaded SVG document in <object> tag."); 
+                failed = true;
+            } else 
+                debug("PASS: Did not load SVG document in <object> tag");
+            
+            try {
+                svgDoc = document.getElementById('svgEmbed').getSVGDocument();
+            } catch (e) {
+                svgDoc = null;
+            }
+            if (svgDoc) {
+                debug("FAIL: Loaded SVG document in <element> tag."); 
+                failed = true;
+            } else 
+                debug("PASS: Did not load SVG document in <element> tag");
+            
+            try {
+                svgDoc = document.getElementById('svgIFrame').getSVGDocument();
+            } catch (e) {
+                svgDoc = null;
+            }
+            if (svgDoc) {
+                debug("FAIL: Loaded SVG document in <iframe> tag."); 
+                failed = true;
+            } else 
+                debug("PASS: Did not load SVG document in <iframe> tag");
+            
+            if (failed)
+                debug("FAIL: SVG Documents were loaded");
+            else
+                debug("PASS: SVG Documents were not loaded");
+        } catch (e) {
+            debug("FAIL: Exception thrown: " + e)
+        }
+        if (window.layoutTestController) 
+            layoutTestController.notifyDone();
+    }
+</script>
+    
+   <object id="svgObject" data="../W3C-SVG-1.1/text-ws-02-t.svg" width="100px" height="100px"></object>
+   <embed id="svgElement" src="../W3C-SVG-1.1/text-ws-02-t.svg" width="100px" height="100px"></embed>
+   <iframe id="svgIFrame" src="../W3C-SVG-1.1/text-ws-02-t.svg" width="100px" height="100px"></iframe>
+   <pre id="console"></pre>    
+</body>
+</html>
index d067470ea54d5f1a3f4b4d9b7725bab2b3905341..00a5be506cb1eeff675eb8606a4c62e73314a04b 100644 (file)
@@ -1,3 +1,28 @@
+2007-05-11  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Brady.
+        
+        <rdar://problem/5017375> WebKit should disable SVG in Dashboard
+        
+        Prevents an SVG document or element from being created when in
+        dashboard compatibility mode.
+        
+        Manually parsing, or using XHR to created a document removes our 
+        ability to detect Dashboard compatibility mode, so we also perform
+        the check when importing nodes from one document into another.
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createDocument):
+          Don't create an SVGDocument if we're in dashboard compatibility mode
+          
+        * dom/Document.cpp:
+        (WebCore::Document::importNode):
+          Don't import SVG nodes if we're in dashboard compatibility mode
+          
+        * ksvg2/scripts/make_names.pl:
+          Don't create SVG elements for documents that are in dashboard
+          compatibility mode
+
 2007-05-11  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Reviewed by Maciej.
index 7c59588c75cf1ce567f8d8832ebab998e9c71bb2..c4fb9b74c778db56f45e89cda67f5baba1b70c65 100644 (file)
@@ -30,6 +30,7 @@
 #include "DocumentType.h"
 #include "Element.h"
 #include "ExceptionCode.h"
+#include "Frame.h"
 #include "HTMLDocument.h"
 #include "HTMLViewSourceDocument.h"
 #include "Image.h"
@@ -38,6 +39,7 @@
 #include "PluginDocument.h"
 #include "PlugInInfoStore.h"
 #include "RegularExpression.h"
+#include "Settings.h"
 #include "TextDocument.h"
 #include "XMLNames.h"
 
@@ -364,7 +366,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
         return new PluginDocument(this, frame);
 
 #if ENABLE(SVG)
-    if (type == "image/svg+xml")
+    if (type == "image/svg+xml" && (!frame || !frame->settings()->usesDashboardBackwardCompatibilityMode()))
         return new SVGDocument(this, frame);
 #endif
     if (isXMLMIMEType(type))
index aef5d03a5d6c17f475747e456cd64ec396e49641..87933d1fa31d7aa9ea717dce0ee665ebb844ef1f 100644 (file)
@@ -74,6 +74,7 @@
 #include "NodeFilter.h"
 #include "NodeIterator.h"
 #include "OverflowEvent.h"
+#include "Page.h"
 #include "PlatformKeyboardEvent.h"
 #include "ProcessingInstruction.h"
 #include "RegisteredEventListener.h"
@@ -553,7 +554,7 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo
 {
     ec = 0;
     
-    if (!importedNode) {
+    if (!importedNode || (importedNode->isSVGElement() && page() && page()->settings()->usesDashboardBackwardCompatibilityMode())) {
         ec = NOT_SUPPORTED_ERR;
         return 0;
     }
index e6eddbcbcf64b3b6b8e9629022124ae33f0ad5d6..3691d281efb4863024b5b5426e5f6688e36b3cd2 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# Copyright (C) 2005, 2006 Apple Computer, Inc.  All rights reserved.
+# Copyright (C) 2005, 2006, 2007 Apple, Inc.  All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -391,6 +391,8 @@ print <<END
 #include "config.h"
 #include "${namespace}ElementFactory.h"
 #include "${namespace}Names.h"
+#include "Page.h"
+#include "Settings.h"
 END
 ;
 
@@ -436,8 +438,8 @@ print <<END
 ${namespace}Element *${namespace}ElementFactory::create${namespace}Element(const QualifiedName& qName, Document* doc, bool createdByParser)
 {
 #if ENABLE(SVG)
-    if (!doc)
-        return 0; // Do not allow elements to ever be made without having a doc.
+    if (!doc || (doc->page() && doc->page()->settings()->usesDashboardBackwardCompatibilityMode()))
+        return 0; // Do not allow elements to ever be made without having a doc or if we're in dashboard compatibility mode.
 
     createFunctionMapIfNecessary();
     ConstructorFunc func = gFunctionMap->get(qName.localName().impl());