diff --git a/testing/web-platform/tests/interfaces/xslt.idl b/testing/web-platform/tests/interfaces/xslt.idl new file mode 100644 index 000000000000..e97d8b000441 --- /dev/null +++ b/testing/web-platform/tests/interfaces/xslt.idl @@ -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(); +}; diff --git a/testing/web-platform/tests/xslt/META.yml b/testing/web-platform/tests/xslt/META.yml new file mode 100644 index 000000000000..9c059d2e9117 --- /dev/null +++ b/testing/web-platform/tests/xslt/META.yml @@ -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 diff --git a/testing/web-platform/tests/xslt/externalScript.js b/testing/web-platform/tests/xslt/externalScript.js new file mode 100644 index 000000000000..7a2bf3622554 --- /dev/null +++ b/testing/web-platform/tests/xslt/externalScript.js @@ -0,0 +1 @@ +window.externalScript = true; diff --git a/testing/web-platform/tests/xslt/idlharness.window.js b/testing/web-platform/tests/xslt/idlharness.window.js new file mode 100644 index 000000000000..51b0cd3dbac7 --- /dev/null +++ b/testing/web-platform/tests/xslt/idlharness.window.js @@ -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(); + } +); diff --git a/testing/web-platform/tests/xslt/transformToFragment.tentative.window.js b/testing/web-platform/tests/xslt/transformToFragment.tentative.window.js new file mode 100644 index 000000000000..7bb6a5685544 --- /dev/null +++ b/testing/web-platform/tests/xslt/transformToFragment.tentative.window.js @@ -0,0 +1,39 @@ +const cases = { + internal: '', + external: '', +}; + +const loaded = new Promise(resolve => { + window.addEventListener('load', resolve); +}); + +Object.entries(cases).forEach(([k, v]) => { + const xsltSrc = ` + + +
+ ${v} +
+
+
`; + + const processor = new XSLTProcessor(); + const parser = new DOMParser(); + processor.importStylesheet( + parser.parseFromString(xsltSrc, 'application/xml') + ); + document.body.appendChild( + processor.transformToFragment( + parser.parseFromString('', 'application/xml'), + document + ) + ); + + promise_test(async () => { + await loaded; + assert_true( + window[`${k}Script`], + 'script element from XSLTProcessor.transformToFragment() is evaluated' + ); + }, `${k} script`); +})