contentDocument and getSVGDocument() are always null for <object> embedding SVG
Categories
(Core :: SVG, defect)
Tracking
()
People
(Reporter: r, Unassigned)
Details
Attachments
(3 files, 1 obsolete file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:103.0) Gecko/20100101 Firefox/103.0
Steps to reproduce:
In an HTML file, embed an SVG in an <object> element, and add a script that accesses the <object> element's contentDocument or calls getSVGDocument() on it. Serve the HTML and SVG files from the same domain.
test.html:
<!doctype html>
<object type="image/svg+xml" width="100" height="100" data="test.svg"></object>
<script>
let obj = document.querySelector('object');
obj.addEventListener('load', function() {
console.log('contentDocument is', obj.contentDocument);
console.log('getSVGDocument returns', obj.getSVGDocument());
});
</script>
test.svg:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red" />
</svg>
Actual results:
Both values are null.
Expected results:
Both values should be the SVG's content document.
This is the expected behaviour as documented here: https://developer.mozilla.org/en-US/docs/Web/SVG/Scripting and as observed in Chromium (93.0.4530.0) and Safari (12.1.2)
The values should be null on cross-origin access, but this shouldn't apply here as both files are served from the same domain.
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::SVG' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•3 years ago
|
||
Comment 3•3 years ago
|
||
Updated•3 years ago
|
Comment 4•3 years ago
|
||
Comment 5•3 years ago
|
||
Seems OK to me when I run your testcase. I'm using a Mac too.
Just to make sure the setup is identical, I've uploaded the test case to a server: https://foon.uk/x/firefox-bug/test.html
I've put Firefox in "Troubleshooting Mode" which I understand disables all customizations, and I still get null.
Screenshot: https://i.imgur.com/DDycglC.png
Comment 8•3 years ago
|
||
That works for me too. Perhaps an extension you have is causing problems. Try safe mode.
Comment 9•3 years ago
|
||
The reporter said
I've put Firefox in "Troubleshooting Mode" which I understand disables all customizations, and I still get null.
(Troubleshooting Mode == safe mode)
Description
•