From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../test/eventsource/eventsource.resource | 22 +++++++ .../test/eventsource/eventsource.resource^headers^ | 3 + .../eventsource/eventsource_cors_response.html | 75 ++++++++++++++++++++++ .../eventsource_cors_response_intercept_worker.js | 30 +++++++++ .../eventsource_mixed_content_cors_response.html | 75 ++++++++++++++++++++++ ...mixed_content_cors_response_intercept_worker.js | 29 +++++++++ .../eventsource/eventsource_opaque_response.html | 75 ++++++++++++++++++++++ ...eventsource_opaque_response_intercept_worker.js | 30 +++++++++ .../eventsource/eventsource_register_worker.html | 27 ++++++++ .../eventsource_synthetic_response.html | 75 ++++++++++++++++++++++ ...ntsource_synthetic_response_intercept_worker.js | 27 ++++++++ .../test/eventsource/eventsource_worker_helper.js | 17 +++++ 12 files changed, 485 insertions(+) create mode 100644 dom/serviceworkers/test/eventsource/eventsource.resource create mode 100644 dom/serviceworkers/test/eventsource/eventsource.resource^headers^ create mode 100644 dom/serviceworkers/test/eventsource/eventsource_cors_response.html create mode 100644 dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js create mode 100644 dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response.html create mode 100644 dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response_intercept_worker.js create mode 100644 dom/serviceworkers/test/eventsource/eventsource_opaque_response.html create mode 100644 dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js create mode 100644 dom/serviceworkers/test/eventsource/eventsource_register_worker.html create mode 100644 dom/serviceworkers/test/eventsource/eventsource_synthetic_response.html create mode 100644 dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js create mode 100644 dom/serviceworkers/test/eventsource/eventsource_worker_helper.js (limited to 'dom/serviceworkers/test/eventsource') diff --git a/dom/serviceworkers/test/eventsource/eventsource.resource b/dom/serviceworkers/test/eventsource/eventsource.resource new file mode 100644 index 0000000000..eb62cbd4c5 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource.resource @@ -0,0 +1,22 @@ +:this file must be enconded in utf8 +:and its Content-Type must be equal to text/event-stream + +retry:500 +data: 2 +unknow: unknow + +event: other_event_name +retry:500 +data: 2 +unknow: unknow + +event: click +retry:500 + +event: blur +retry:500 + +event:keypress +retry:500 + + diff --git a/dom/serviceworkers/test/eventsource/eventsource.resource^headers^ b/dom/serviceworkers/test/eventsource/eventsource.resource^headers^ new file mode 100644 index 0000000000..5b88be7c32 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource.resource^headers^ @@ -0,0 +1,3 @@ +Content-Type: text/event-stream +Cache-Control: no-cache, must-revalidate +Access-Control-Allow-Origin: * diff --git a/dom/serviceworkers/test/eventsource/eventsource_cors_response.html b/dom/serviceworkers/test/eventsource/eventsource_cors_response.html new file mode 100644 index 0000000000..115a0f5c65 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_cors_response.html @@ -0,0 +1,75 @@ + + + + + Bug 1182103 - Test EventSource scenarios with fetch interception + + + + + diff --git a/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js new file mode 100644 index 0000000000..c2e5d416e7 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js @@ -0,0 +1,30 @@ +// Cross origin request +var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; + +self.importScripts("eventsource_worker_helper.js"); + +self.addEventListener("fetch", function (event) { + var request = event.request; + var url = new URL(request.url); + + if ( + url.pathname !== + "/tests/dom/serviceworkers/test/eventsource/eventsource.resource" + ) { + return; + } + + ok(request.mode === "cors", "EventSource should make a CORS request"); + ok( + request.cache === "no-store", + "EventSource should make a no-store request" + ); + var fetchRequest = new Request(prefix + "eventsource.resource", { + mode: "cors", + }); + event.respondWith( + fetch(fetchRequest).then(fetchResponse => { + return fetchResponse; + }) + ); +}); diff --git a/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response.html b/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response.html new file mode 100644 index 0000000000..970cae517f --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response.html @@ -0,0 +1,75 @@ + + + + + Bug 1182103 - Test EventSource scenarios with fetch interception + + + + + diff --git a/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response_intercept_worker.js new file mode 100644 index 0000000000..9cb8d2d61f --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_mixed_content_cors_response_intercept_worker.js @@ -0,0 +1,29 @@ +var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; + +self.importScripts("eventsource_worker_helper.js"); + +self.addEventListener("fetch", function (event) { + var request = event.request; + var url = new URL(request.url); + + if ( + url.pathname !== + "/tests/dom/serviceworkers/test/eventsource/eventsource.resource" + ) { + return; + } + + ok(request.mode === "cors", "EventSource should make a CORS request"); + ok( + request.cache === "no-store", + "EventSource should make a no-store request" + ); + var fetchRequest = new Request(prefix + "eventsource.resource", { + mode: "cors", + }); + event.respondWith( + fetch(fetchRequest).then(fetchResponse => { + return fetchResponse; + }) + ); +}); diff --git a/dom/serviceworkers/test/eventsource/eventsource_opaque_response.html b/dom/serviceworkers/test/eventsource/eventsource_opaque_response.html new file mode 100644 index 0000000000..bce12259cc --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_opaque_response.html @@ -0,0 +1,75 @@ + + + + + Bug 1182103 - Test EventSource scenarios with fetch interception + + + + + diff --git a/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js new file mode 100644 index 0000000000..5c8c75a161 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js @@ -0,0 +1,30 @@ +// Cross origin request +var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; + +self.importScripts("eventsource_worker_helper.js"); + +self.addEventListener("fetch", function (event) { + var request = event.request; + var url = new URL(request.url); + + if ( + url.pathname !== + "/tests/dom/serviceworkers/test/eventsource/eventsource.resource" + ) { + return; + } + + ok(request.mode === "cors", "EventSource should make a CORS request"); + ok( + request.cache === "no-store", + "EventSource should make a no-store request" + ); + var fetchRequest = new Request(prefix + "eventsource.resource", { + mode: "no-cors", + }); + event.respondWith( + fetch(fetchRequest).then(fetchResponse => { + return fetchResponse; + }) + ); +}); diff --git a/dom/serviceworkers/test/eventsource/eventsource_register_worker.html b/dom/serviceworkers/test/eventsource/eventsource_register_worker.html new file mode 100644 index 0000000000..59e8e92ab6 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_register_worker.html @@ -0,0 +1,27 @@ + + + + + Bug 1182103 - Test EventSource scenarios with fetch interception + + + + + diff --git a/dom/serviceworkers/test/eventsource/eventsource_synthetic_response.html b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response.html new file mode 100644 index 0000000000..7f6228c91e --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response.html @@ -0,0 +1,75 @@ + + + + + Bug 1182103 - Test EventSource scenarios with fetch interception + + + + + diff --git a/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js new file mode 100644 index 0000000000..72780e2979 --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js @@ -0,0 +1,27 @@ +self.importScripts("eventsource_worker_helper.js"); + +self.addEventListener("fetch", function (event) { + var request = event.request; + var url = new URL(request.url); + + if ( + url.pathname !== + "/tests/dom/serviceworkers/test/eventsource/eventsource.resource" + ) { + return; + } + + ok(request.mode === "cors", "EventSource should make a CORS request"); + var headerList = { + "Content-Type": "text/event-stream", + "Cache-Control": "no-cache, must-revalidate", + }; + var headers = new Headers(headerList); + var init = { + headers, + mode: "cors", + }; + var body = "data: data0\r\r"; + var response = new Response(body, init); + event.respondWith(response); +}); diff --git a/dom/serviceworkers/test/eventsource/eventsource_worker_helper.js b/dom/serviceworkers/test/eventsource/eventsource_worker_helper.js new file mode 100644 index 0000000000..676d2a4bbe --- /dev/null +++ b/dom/serviceworkers/test/eventsource/eventsource_worker_helper.js @@ -0,0 +1,17 @@ +function ok(aCondition, aMessage) { + return new Promise(function (resolve, reject) { + self.clients.matchAll().then(function (res) { + if (!res.length) { + reject(); + return; + } + res[0].postMessage({ + status: "callback", + data: "ok", + condition: aCondition, + message: aMessage, + }); + resolve(); + }); + }); +} -- cgit v1.2.3