Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid disabling Firefox XML pretty printing #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinoid
Copy link

Firefox displays XML documents with unsupported namespaces that lack XSL stylesheets using nsXMLPrettyPrinter which produces an interactive tree view of the XML content. If any content is appended, the pretty printing is disabled because it no longer matches the modified DOM. This was modified in Bug 1605657 to exclude changes made by by extensions during document_start, but it does not exclude changes made later (e.g. on DOMContentLoaded as this extension does).

Rather than injecting the <script> during document_start, this pull request takes the approach of React DeveloperTools and only injects scripts for (X)HTML documents. Note that this pull request additionally recognizes XHTML documents served as application/xml or text/xml by checking the namespace of the document element. Even with this additional coverage, it does not recognize embedded XHTML (such as <xhtml:video> in SVG) or other exotic document types. DOM traversal could be added to cover more of these cases, if desired.

Thanks for considering,
Kevin

Firefox displays XML documents with unsupported namespaces that lack
XSL stylesheets using nsXMLPrettyPrinter which produces an interactive
tree view of the XML content.  If any content is appended, the [pretty
printing is disabled] because it [no longer matches the modified DOM].
This was modified in [Bug 1605657] to exclude changes made by by
extensions during document_start, but it does not exclude changes made
later (e.g. on DOMContentLoaded as this extension does).

Rather than injecting the <script> during document_start, this commit
takes the [approach of React DeveloperTools] and only injects scripts
for (X)HTML documents.  Note that this commit additionally recognizes
XHTML documents served as application/xml or text/xml by checking the
namespace of the document element.  Even with this additional coverage,
it does not recognize embedded XHTML (such as <xhtml:video> in SVG) or
other exotic document types.  DOM traversal could be added to cover
more of these cases, if desired.

[pretty printing is disabled]: https://searchfox.org/mozilla-central/rev/692215ac0263906577c610a4ebd32822834bd398/dom/xml/nsXMLPrettyPrinter.cpp#152
[no longer matches the modified DOM]: https://bugzilla.mozilla.org/show_bug.cgi?id=1605657#c26
[Bug 1605657]: https://bugzilla.mozilla.org/1605657
[approach of React DeveloperTools]: facebook/react#1773

Signed-off-by: Kevin Locke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant