Bug 1565397 [wpt PR 17607] - Add an xslt test folder, a=testonly

Automatic update from web-platform-tests
Add an xslt test folder (#17607)

* Add xslt test transformToFragment test
* Add IDL + test
--

wpt-commits: ab9626fa6be42c01576385327da84a6f7e9144b8
wpt-pr: 17607
This commit is contained in:
Luke Bjerring 2019-07-22 11:07:21 +00:00 коммит произвёл James Graham
Родитель 2d5484731d
Коммит b62df0064a
5 изменённых файлов: 75 добавлений и 0 удалений

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

@ -0,0 +1,16 @@
// Content was manually copied July 12 2019
// Source: https://wiki.whatwg.org/wiki/DOM_XSLTProcessor
// There is no standard for this API. Only the link above, and notes in
// the HTML5 standard (https://html.spec.whatwg.org/multipage/scripting.html#scriptTagXSLT)
[Exposed=Window, Constructor]
interface XSLTProcessor {
void importStylesheet(Node style);
[CEReactions] DocumentFragment transformToFragment(Node source, Document output);
[CEReactions] Document transformToDocument(Node source);
void setParameter([TreatNullAs=EmptyString] DOMString namespaceURI, DOMString localName, any value);
any getParameter([TreatNullAs=EmptyString] DOMString namespaceURI, DOMString localName);
void removeParameter([TreatNullAs=EmptyString] DOMString namespaceURI, DOMString localName);
void clearParameters();
void reset();
};

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

@ -0,0 +1,4 @@
# NOTE: There is no standard for this API, only:
# https://wiki.whatwg.org/wiki/DOM_XSLTProcessor
# and the notes in the HTML5 spec, linked.
spec: https://html.spec.whatwg.org/multipage/scripting.html#scriptTagXSLT

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

@ -0,0 +1 @@
window.externalScript = true;

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

@ -0,0 +1,15 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
'use strict';
idl_test(
['xslt'],
['html'],
async idlArray => {
idlArray.add_objects({
XSLTProcessor: ['processor']
});
self.processor = new XSLTProcessor();
}
);

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

@ -0,0 +1,39 @@
const cases = {
internal: '<script>window.internalScript = true;</script>',
external: '<script src="externalScript.js"></script>',
};
const loaded = new Promise(resolve => {
window.addEventListener('load', resolve);
});
Object.entries(cases).forEach(([k, v]) => {
const xsltSrc = `<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" version="5"/>
<xsl:template match="/">
<section>
${v}
</section>
</xsl:template>
</xsl:stylesheet>`;
const processor = new XSLTProcessor();
const parser = new DOMParser();
processor.importStylesheet(
parser.parseFromString(xsltSrc, 'application/xml')
);
document.body.appendChild(
processor.transformToFragment(
parser.parseFromString('<x/>', 'application/xml'),
document
)
);
promise_test(async () => {
await loaded;
assert_true(
window[`${k}Script`],
'script element from XSLTProcessor.transformToFragment() is evaluated'
);
}, `${k} script`);
})