Diff
Modified: trunk/LayoutTests/ChangeLog (116684 => 116685)
--- trunk/LayoutTests/ChangeLog 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/LayoutTests/ChangeLog 2012-05-10 21:09:31 UTC (rev 116685)
@@ -1,3 +1,13 @@
+2012-05-10 Brady Eidson <[email protected]>
+
+ <rdar://problem/10972577> and https://bugs.webkit.org/show_bug.cgi?id=80170
+ Contents of noscript elements turned into strings in WebArchives
+
+ Reviewed by Andy Estes.
+
+ * webarchive/ignore-noscript-if-scripting-enabled-expected.txt: Added.
+ * webarchive/ignore-noscript-if-scripting-enabled.html: Added.
+
2012-05-10 Abhishek Arya <[email protected]>
Crash due to floats not removed from first-letter element.
Added: trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled-expected.txt (0 => 116685)
--- trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled-expected.txt (rev 0)
+++ trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled-expected.txt 2012-05-10 21:09:31 UTC (rev 116685)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>WebMainResource</key>
+ <dict>
+ <key>WebResourceData</key>
+ <string><html><head>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpDOMAsWebArchive();
+</script>
+</head>
+<body>
+This should appear in the webarchive.
+
+
+
+</body></html></string>
+ <key>WebResourceFrameName</key>
+ <string></string>
+ <key>WebResourceMIMEType</key>
+ <string>text/html</string>
+ <key>WebResourceTextEncodingName</key>
+ <string>UTF-8</string>
+ <key>WebResourceURL</key>
+ <string>file:///LayoutTests/webarchive/ignore-noscript-if-scripting-enabled.html</string>
+ </dict>
+</dict>
+</plist>
Added: trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled.html (0 => 116685)
--- trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled.html (rev 0)
+++ trunk/LayoutTests/webarchive/ignore-noscript-if-scripting-enabled.html 2012-05-10 21:09:31 UTC (rev 116685)
@@ -0,0 +1,14 @@
+<html>
+<head>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpDOMAsWebArchive();
+</script>
+</head>
+<body>
+This should appear in the webarchive.
+<noscript>
+Assuming scripting was enabled earlier, this should *not* appear in the webarchive.
+</noscript>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (116684 => 116685)
--- trunk/Source/WebCore/ChangeLog 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/ChangeLog 2012-05-10 21:09:31 UTC (rev 116685)
@@ -1,3 +1,34 @@
+2012-05-10 Brady Eidson <[email protected]>
+
+ <rdar://problem/10972577> and https://bugs.webkit.org/show_bug.cgi?id=80170
+ Contents of noscript elements turned into strings in WebArchives
+
+ Reviewed by Andy Estes.
+
+ There's a much deeper question about how innerHTML of <noscript> is expected to work in
+ both a scripting and non-scripting environment that we should pursue separately.
+
+ But for webarchives, we can solve this by filtering out the <noscript> elements completely
+ if scripting is enabled.
+
+ Test: webarchive/ignore-noscript-if-scripting-enabled.html
+
+ * WebCore.exp.in:
+
+ Add arguments to createMarkup and MarkupAccumulator methods to pass a Vector of QualifiedNames
+ that should be filtered from the resulting markup:
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::serializeNodes):
+ (WebCore::MarkupAccumulator::serializeNodesWithNamespaces):
+ * editing/MarkupAccumulator.h:
+ * editing/markup.cpp:
+ (WebCore::createMarkup):
+ * editing/markup.h:
+
+ If scripting is enabled, add the noscriptTag to the tag names to filter:
+ * loader/archive/cf/LegacyWebArchive.cpp:
+ (WebCore::LegacyWebArchive::create):
+
2012-05-10 Abhishek Arya <[email protected]>
Crash due to floats not removed from first-letter element.
Modified: trunk/Source/WebCore/WebCore.exp.in (116684 => 116685)
--- trunk/Source/WebCore/WebCore.exp.in 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-05-10 21:09:31 UTC (rev 116685)
@@ -293,7 +293,7 @@
__ZN7WebCore12WorkerThread17workerThreadCountEv
#endif
__ZN7WebCore12cacheStorageEv
-__ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsE
+__ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsEPNS5_INS_13QualifiedNameELm0EEE
__ZN7WebCore12createMarkupEPKNS_5RangeEPN3WTF6VectorIPNS_4NodeELm0EEENS_23EAnnotateForInterchangeEbNS_13EAbsoluteURLsE
__ZN7WebCore12gcControllerEv
__ZN7WebCore12iconDatabaseEv
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (116684 => 116685)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-05-10 21:09:31 UTC (rev 116685)
@@ -86,14 +86,26 @@
String MarkupAccumulator::serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly)
{
- serializeNodesWithNamespaces(targetNode, nodeToSkip, childrenOnly, 0);
+ return serializeNodes(targetNode, nodeToSkip, childrenOnly, 0);
+}
+
+String MarkupAccumulator::serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, Vector<QualifiedName>* tagNamesToSkip)
+{
+ serializeNodesWithNamespaces(targetNode, nodeToSkip, childrenOnly, 0, tagNamesToSkip);
return m_markup.toString();
}
-void MarkupAccumulator::serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, const Namespaces* namespaces)
+void MarkupAccumulator::serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly childrenOnly, const Namespaces* namespaces, Vector<QualifiedName>* tagNamesToSkip)
{
if (targetNode == nodeToSkip)
return;
+
+ if (tagNamesToSkip) {
+ for (size_t i = 0; i < tagNamesToSkip->size(); ++i) {
+ if (targetNode->hasTagName(tagNamesToSkip->at(i)))
+ return;
+ }
+ }
Namespaces namespaceHash;
if (namespaces)
@@ -104,7 +116,7 @@
if (!(targetNode->document()->isHTMLDocument() && elementCannotHaveEndTag(targetNode))) {
for (Node* current = targetNode->firstChild(); current; current = current->nextSibling())
- serializeNodesWithNamespaces(current, nodeToSkip, IncludeNode, &namespaceHash);
+ serializeNodesWithNamespaces(current, nodeToSkip, IncludeNode, &namespaceHash, tagNamesToSkip);
}
if (!childrenOnly)
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.h (116684 => 116685)
--- trunk/Source/WebCore/editing/MarkupAccumulator.h 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.h 2012-05-10 21:09:31 UTC (rev 116685)
@@ -71,6 +71,7 @@
virtual ~MarkupAccumulator();
String serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly);
+ String serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly, Vector<QualifiedName>* tagNamesToSkip);
static void appendComment(StringBuilder&, const String&);
@@ -108,7 +109,7 @@
private:
String resolveURLIfNeeded(const Element*, const String&) const;
void appendQuotedURLAttributeValue(StringBuilder&, const Element*, const Attribute&);
- void serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly, const Namespaces*);
+ void serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip);
StringBuilder m_markup;
const EAbsoluteURLs m_resolveURLsMethod;
Modified: trunk/Source/WebCore/editing/markup.cpp (116684 => 116685)
--- trunk/Source/WebCore/editing/markup.cpp 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/editing/markup.cpp 2012-05-10 21:09:31 UTC (rev 116685)
@@ -759,7 +759,7 @@
return fragment;
}
-String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs)
+String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip)
{
if (!node)
return "";
@@ -772,7 +772,7 @@
}
MarkupAccumulator accumulator(nodes, shouldResolveURLs);
- return accumulator.serializeNodes(const_cast<Node*>(node), deleteButtonContainerElement, childrenOnly);
+ return accumulator.serializeNodes(const_cast<Node*>(node), deleteButtonContainerElement, childrenOnly, tagNamesToSkip);
}
static void fillContainerFromString(ContainerNode* paragraph, const String& string)
Modified: trunk/Source/WebCore/editing/markup.h (116684 => 116685)
--- trunk/Source/WebCore/editing/markup.h 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/editing/markup.h 2012-05-10 21:09:31 UTC (rev 116685)
@@ -39,6 +39,7 @@
class Element;
class KURL;
class Node;
+ class QualifiedName;
class Range;
typedef int ExceptionCode;
@@ -60,7 +61,7 @@
String createMarkup(const Range*,
Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
- String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs);
+ String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = 0);
String createFullMarkup(const Node*);
String createFullMarkup(const Range*);
Modified: trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp (116684 => 116685)
--- trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp 2012-05-10 21:01:07 UTC (rev 116684)
+++ trunk/Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp 2012-05-10 21:09:31 UTC (rev 116685)
@@ -44,7 +44,9 @@
#include "Logging.h"
#include "markup.h"
#include "Node.h"
+#include "Page.h"
#include "Range.h"
+#include "Settings.h"
#include "SharedBuffer.h"
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -438,9 +440,18 @@
Frame* frame = document ? document->frame() : 0;
if (!frame)
return create();
+
+ // If the page was loaded with _javascript_ enabled, we don't want to archive <noscript> tags
+ // In practice we don't actually know whether scripting was enabled when the page was originally loaded
+ // but we can approximate that by checking if scripting is enabled right now.
+ OwnPtr<Vector<QualifiedName> > tagNamesToFilter;
+ if (frame->page() && frame->page()->settings()->isScriptEnabled()) {
+ tagNamesToFilter = adoptPtr(new Vector<QualifiedName>);
+ tagNamesToFilter->append(HTMLNames::noscriptTag);
+ }
Vector<Node*> nodeList;
- String markupString = createMarkup(node, IncludeNode, &nodeList);
+ String markupString = createMarkup(node, IncludeNode, &nodeList, DoNotResolveURLs, tagNamesToFilter.get());
Node::NodeType nodeType = node->nodeType();
if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
markupString = frame->documentTypeString() + markupString;