Commit 7990272a authored by Robert Longson's avatar Robert Longson
Browse files

Bug 1804339 - Fix relative url conversion for SVG image and script when saving pages r=emilio

parent 61e4227e
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -458,7 +458,9 @@ nsresult ResourceReader::OnWalkDOMNode(nsINode* aNode) {
    return NS_OK;
  }

  if (aNode->IsSVGElement(nsGkAtoms::img)) {
  if (aNode->IsSVGElement(nsGkAtoms::image)) {
    MOZ_TRY(OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_IMAGE,
                            "href"));
    return OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_IMAGE,
                           "href", "http://www.w3.org/1999/xlink");
  }
@@ -500,6 +502,8 @@ nsresult ResourceReader::OnWalkDOMNode(nsINode* aNode) {
  }

  if (aNode->IsSVGElement(nsGkAtoms::script)) {
    MOZ_TRY(OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_SCRIPT,
                            "href"));
    return OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_SCRIPT,
                           "href", "http://www.w3.org/1999/xlink");
  }
@@ -993,7 +997,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
    return rv;
  }

  if (content->IsSVGElement(nsGkAtoms::img)) {
  if (content->IsSVGElement(nsGkAtoms::image)) {
    nsresult rv = GetNodeToFixup(aNodeIn, aNodeOut);
    if (NS_SUCCEEDED(rv) && *aNodeOut) {
      // Disable image loads
@@ -1001,6 +1005,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
      if (imgCon) imgCon->SetLoadingEnabled(false);

      // FixupAnchor(*aNodeOut);  // XXXjwatt: is this line needed?
      FixupAttribute(*aNodeOut, "href");
      FixupAttribute(*aNodeOut, "href", "http://www.w3.org/1999/xlink");
    }
    return rv;
@@ -1017,6 +1022,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
  if (content->IsSVGElement(nsGkAtoms::script)) {
    nsresult rv = GetNodeToFixup(aNodeIn, aNodeOut);
    if (NS_SUCCEEDED(rv) && *aNodeOut) {
      FixupAttribute(*aNodeOut, "href");
      FixupAttribute(*aNodeOut, "href", "http://www.w3.org/1999/xlink");
    }
    return rv;
+1 −0
Original line number Diff line number Diff line
@@ -8,5 +8,6 @@ support-files =
[browser_persist.js]
support-files =
  file_persist_srcset.html
  file_persist_svg.html
  file_persist_picture_source.html
  file_persist_image.png
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ const chromeBase =
const REFTESTS = [
  "file_persist_srcset.html",
  "file_persist_picture_source.html",
  "file_persist_svg.html",
  // ...
];

+5 −0
Original line number Diff line number Diff line
<!doctype html>
<svg>
  <image href="file_persist_image.png"/>
  <image x="100" xlink:href="file_persist_image.png"/>
</svg>