Bug 1481882 - Load customElements.js in chrome XHTML documents;r=mossop

This provides support for using XUL elements in  chrome XHTML documents,
including the experimental xhtml browser window (browser.xhtml).

Differential Revision: https://phabricator.services.mozilla.com/D3432

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Grinstead 2018-08-16 16:26:16 +00:00
Родитель 35b08ddffc
Коммит 7eeeeed53f
4 изменённых файлов: 22 добавлений и 7 удалений

Просмотреть файл

@ -73,13 +73,15 @@ MainProcessSingleton.prototype = {
}
case "document-element-inserted":
// Set up Custom Elements for XUL windows before anything else happens
// in the document. Anything loaded here should be considered part of
// core XUL functionality. Any window-specific elements can be registered
// via <script> tags at the top of individual documents.
// Set up Custom Elements for XUL and XHTML documents before anything else
// happens. Anything loaded here should be considered part of core XUL functionality.
// Any window-specific elements can be registered via <script> tags at the
// top of individual documents.
const doc = subject;
if (doc.nodePrincipal.isSystemPrincipal &&
doc.contentType == "application/vnd.mozilla.xul+xml") {
if (doc.nodePrincipal.isSystemPrincipal && (
doc.contentType == "application/vnd.mozilla.xul+xml" ||
doc.contentType == "application/xhtml+xml"
)) {
Services.scriptloader.loadSubScript(
"chrome://global/content/customElements.js", doc.ownerGlobal);
}

Просмотреть файл

@ -14,6 +14,7 @@ support-files =
bug624329_window.xul
dialog_dialogfocus.xul
dialog_dialogfocus2.xul
file_empty.xhtml
file_about_networking_wsh.py
file_autocomplete_with_composition.js
file_editor_with_autocomplete.js

Просмотреть файл

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns='http://www.w3.org/1999/xhtml'>
</html>

Просмотреть файл

@ -19,10 +19,19 @@
SimpleTest.waitForExplicitFinish();
function runTests() {
async function runTests() {
ok(MozXULElement, "MozXULElement defined on the window");
testParseXULToFragment();
testCustomInterface();
let htmlWin = await new Promise(resolve => {
let htmlIframe = document.createElement("iframe");
htmlIframe.src = "file_empty.xhtml";
htmlIframe.onload = () => resolve(htmlIframe.contentWindow);
document.documentElement.appendChild(htmlIframe);
});
ok(htmlWin.MozXULElement, "MozXULElement defined on a chrome HTML window");
SimpleTest.finish();
}