From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../controlling-ua/support/iframe.html | 181 +++++++++++++++++++++ .../controlling-ua/support/presentation.html | 98 +++++++++++ .../controlling-ua/support/stash.js | 83 ++++++++++ .../controlling-ua/support/stash.py | 10 ++ 4 files changed, 372 insertions(+) create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js create mode 100644 testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py (limited to 'testing/web-platform/tests/presentation-api/controlling-ua/support') diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html b/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html new file mode 100644 index 0000000000..e2171deaa8 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/iframe.html @@ -0,0 +1,181 @@ + + +Presentation API - controlling ua - sandboxing + + + + + + + + diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html b/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html new file mode 100644 index 0000000000..8ad838062f --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/presentation.html @@ -0,0 +1,98 @@ + + + + + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js new file mode 100644 index 0000000000..616907d4f2 --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.js @@ -0,0 +1,83 @@ +var Stash = function(inbound, outbound) { + this.stashPath = '/presentation-api/controlling-ua/support/stash.py?id='; + this.inbound = inbound; + this.outbound = outbound; +} + +// initialize a stash on wptserve +Stash.prototype.init = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]); +} + +// upload a test result to a stash on wptserve +Stash.prototype.send = function(result) { + return fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'data', data: result }) + }).then(response => { + return response.text(); + }).then(text => { + return text === 'ok' ? null : Promise.reject(); + }) +}; + +// wait until a test result is uploaded to a stash on wptserve +Stash.prototype.receive = function() { + return new Promise((resolve, reject) => { + let intervalId; + const interval = 500; // msec + const polling = () => { + return fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }).then(text => { + if (text) { + try { + const json = JSON.parse(text); + if (json.type === 'data') + resolve(json.data); + else + reject(); + } catch(e) { + resolve(text); + } + clearInterval(intervalId); + } + }); + }; + intervalId = setInterval(polling, interval); + }); +}; + +// reset a stash on wptserve +Stash.prototype.stop = function() { + return Promise.all([ + fetch(this.stashPath + this.inbound).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound).then(response => { + return response.text(); + }) + ]).then(() => { + return Promise.all([ + fetch(this.stashPath + this.inbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }), + fetch(this.stashPath + this.outbound, { + method: 'POST', + body: JSON.stringify({ type: 'stop' }) + }).then(response => { + return response.text(); + }) + ]); + }); +} diff --git a/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py new file mode 100644 index 0000000000..83653d365a --- /dev/null +++ b/testing/web-platform/tests/presentation-api/controlling-ua/support/stash.py @@ -0,0 +1,10 @@ +def main(request, response): + key = request.GET.first(b"id") + + if request.method == u"POST": + request.server.stash.put(key, request.body) + return b"ok" + else: + value = request.server.stash.take(key) + assert request.server.stash.take(key) is None + return value \ No newline at end of file -- cgit v1.2.3