From b62df0064ad817b69fb328f58ba8798bfe342342 Mon Sep 17 00:00:00 2001 From: Luke Bjerring Date: Mon, 22 Jul 2019 11:07:21 +0000 Subject: [PATCH] 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 --- .../web-platform/tests/interfaces/xslt.idl | 16 ++++++++ testing/web-platform/tests/xslt/META.yml | 4 ++ .../web-platform/tests/xslt/externalScript.js | 1 + .../tests/xslt/idlharness.window.js | 15 +++++++ .../transformToFragment.tentative.window.js | 39 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 testing/web-platform/tests/interfaces/xslt.idl create mode 100644 testing/web-platform/tests/xslt/META.yml create mode 100644 testing/web-platform/tests/xslt/externalScript.js create mode 100644 testing/web-platform/tests/xslt/idlharness.window.js create mode 100644 testing/web-platform/tests/xslt/transformToFragment.tentative.window.js 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`); +})