diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/serviceworkers | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/serviceworkers')
14 files changed, 72 insertions, 86 deletions
diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp index 531e29e905..6027625021 100644 --- a/dom/serviceworkers/ServiceWorkerEvents.cpp +++ b/dom/serviceworkers/ServiceWorkerEvents.cpp @@ -624,8 +624,7 @@ void RespondWithHandler::ResolvedCallback(JSContext* aCx, if (response->Type() == ResponseType::Opaque && mRequestMode != RequestMode::No_cors) { - NS_ConvertASCIItoUTF16 modeString( - RequestModeValues::GetString(mRequestMode)); + NS_ConvertASCIItoUTF16 modeString(GetEnumString(mRequestMode)); autoCancel.SetCancelMessage("BadOpaqueInterceptionRequestModeWithURL"_ns, mRequestURL, modeString); diff --git a/dom/serviceworkers/ServiceWorkerIPCUtils.h b/dom/serviceworkers/ServiceWorkerIPCUtils.h index bd867f877a..9931af94e7 100644 --- a/dom/serviceworkers/ServiceWorkerIPCUtils.h +++ b/dom/serviceworkers/ServiceWorkerIPCUtils.h @@ -11,6 +11,7 @@ // Undo X11/X.h's definition of None #undef None +#include "mozilla/dom/BindingIPCUtils.h" #include "mozilla/dom/ServiceWorkerBinding.h" #include "mozilla/dom/ServiceWorkerRegistrationBinding.h" @@ -18,17 +19,13 @@ namespace IPC { template <> struct ParamTraits<mozilla::dom::ServiceWorkerState> - : public ContiguousEnumSerializer< - mozilla::dom::ServiceWorkerState, - mozilla::dom::ServiceWorkerState::Parsed, - mozilla::dom::ServiceWorkerState::EndGuard_> {}; + : public mozilla::dom::WebIDLEnumSerializer< + mozilla::dom::ServiceWorkerState> {}; template <> struct ParamTraits<mozilla::dom::ServiceWorkerUpdateViaCache> - : public ContiguousEnumSerializer< - mozilla::dom::ServiceWorkerUpdateViaCache, - mozilla::dom::ServiceWorkerUpdateViaCache::Imports, - mozilla::dom::ServiceWorkerUpdateViaCache::EndGuard_> {}; + : public mozilla::dom::WebIDLEnumSerializer< + mozilla::dom::ServiceWorkerUpdateViaCache> {}; } // namespace IPC diff --git a/dom/serviceworkers/ServiceWorkerInfo.cpp b/dom/serviceworkers/ServiceWorkerInfo.cpp index 9998cfed6b..2689af6ee9 100644 --- a/dom/serviceworkers/ServiceWorkerInfo.cpp +++ b/dom/serviceworkers/ServiceWorkerInfo.cpp @@ -43,7 +43,7 @@ static_assert(nsIServiceWorkerInfo::STATE_REDUNDANT == "ServiceWorkerState enumeration value should match state values " "from nsIServiceWorkerInfo."); static_assert(nsIServiceWorkerInfo::STATE_UNKNOWN == - ServiceWorkerStateValues::Count, + ContiguousEnumSize<ServiceWorkerState>::value, "ServiceWorkerState enumeration value should match state values " "from nsIServiceWorkerInfo."); @@ -165,8 +165,6 @@ void ServiceWorkerInfo::UpdateState(ServiceWorkerState aState) { // Any state can directly transition to redundant, but everything else is // ordered. if (aState != ServiceWorkerState::Redundant) { - MOZ_ASSERT_IF(State() == ServiceWorkerState::EndGuard_, - aState == ServiceWorkerState::Installing); MOZ_ASSERT_IF(State() == ServiceWorkerState::Installing, aState == ServiceWorkerState::Installed); MOZ_ASSERT_IF(State() == ServiceWorkerState::Installed, diff --git a/dom/serviceworkers/ServiceWorkerManager.cpp b/dom/serviceworkers/ServiceWorkerManager.cpp index b0dcfca893..842939d785 100644 --- a/dom/serviceworkers/ServiceWorkerManager.cpp +++ b/dom/serviceworkers/ServiceWorkerManager.cpp @@ -127,7 +127,7 @@ static_assert( static_cast<uint32_t>(RequestRedirect::Manual), "RequestRedirect enumeration value should make Necko Redirect mode value."); static_assert( - 3 == RequestRedirectValues::Count, + 3 == ContiguousEnumSize<RequestRedirect>::value, "RequestRedirect enumeration value should make Necko Redirect mode value."); static_assert( @@ -155,7 +155,7 @@ static_assert( static_cast<uint32_t>(RequestCache::Only_if_cached), "RequestCache enumeration value should match Necko Cache mode value."); static_assert( - 6 == RequestCacheValues::Count, + 6 == ContiguousEnumSize<RequestCache>::value, "RequestCache enumeration value should match Necko Cache mode value."); static_assert(static_cast<uint16_t>(ServiceWorkerUpdateViaCache::Imports) == diff --git a/dom/serviceworkers/ServiceWorkerManagerParent.cpp b/dom/serviceworkers/ServiceWorkerManagerParent.cpp index 5ed0f4faa8..d2d0a64275 100644 --- a/dom/serviceworkers/ServiceWorkerManagerParent.cpp +++ b/dom/serviceworkers/ServiceWorkerManagerParent.cpp @@ -91,9 +91,9 @@ mozilla::ipc::IPCResult ServiceWorkerManagerParent::RecvPropagateUnregister( // one and only ServiceWorkerManager, but it is necessary for us to have run // the unregister call above because until Bug 1183245 is fixed, // nsIServiceWorkerManager.propagateUnregister() is a de facto API for - // clearing ServiceWorker registrations by Sanitizer.jsm via - // ServiceWorkerCleanUp.jsm, as well as devtools "unregister" affordance and - // the no-longer-relevant about:serviceworkers UI. + // clearing ServiceWorker registrations by Sanitizer.sys.mjs via + // ServiceWorkerCleanUp.sys.mjs, as well as devtools "unregister" affordance + // and the no-longer-relevant about:serviceworkers UI. return IPC_OK(); } diff --git a/dom/serviceworkers/ServiceWorkerOp.cpp b/dom/serviceworkers/ServiceWorkerOp.cpp index 8811404a0f..9c4fc569d1 100644 --- a/dom/serviceworkers/ServiceWorkerOp.cpp +++ b/dom/serviceworkers/ServiceWorkerOp.cpp @@ -1428,8 +1428,7 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx, if (response->Type() == ResponseType::Opaque && requestMode != RequestMode::No_cors) { - NS_ConvertASCIItoUTF16 modeString( - RequestModeValues::GetString(requestMode)); + NS_ConvertASCIItoUTF16 modeString(GetEnumString(requestMode)); nsAutoString requestURL; GetRequestURL(requestURL); diff --git a/dom/serviceworkers/test/browser_download.js b/dom/serviceworkers/test/browser_download.js index 0c69a48d17..70622a2349 100644 --- a/dom/serviceworkers/test/browser_download.js +++ b/dom/serviceworkers/test/browser_download.js @@ -3,7 +3,7 @@ var gTestRoot = getRootDirectory(gTestPath).replace( "chrome://mochitests/content/", - "http://mochi.test:8888/" + "https://example.com/" ); function getFile(aFilename) { diff --git a/dom/serviceworkers/test/close_test.js b/dom/serviceworkers/test/close_test.js index 07f85617ef..0609782e5e 100644 --- a/dom/serviceworkers/test/close_test.js +++ b/dom/serviceworkers/test/close_test.js @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + function ok(v, msg) { client.postMessage({ status: "ok", result: !!v, message: msg }); } diff --git a/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js index c2e5d416e7..31a8165625 100644 --- a/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js +++ b/dom/serviceworkers/test/eventsource/eventsource_cors_response_intercept_worker.js @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + // Cross origin request var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; 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 index 9cb8d2d61f..9cfca63db9 100644 --- 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 @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; self.importScripts("eventsource_worker_helper.js"); diff --git a/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js index 5c8c75a161..84d406ac47 100644 --- a/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js +++ b/dom/serviceworkers/test/eventsource/eventsource_opaque_response_intercept_worker.js @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + // Cross origin request var prefix = "http://example.com/tests/dom/serviceworkers/test/eventsource/"; diff --git a/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js index 72780e2979..ec3f0309c2 100644 --- a/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js +++ b/dom/serviceworkers/test/eventsource/eventsource_synthetic_response_intercept_worker.js @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + self.importScripts("eventsource_worker_helper.js"); self.addEventListener("fetch", function (event) { diff --git a/dom/serviceworkers/test/gtest/TestReadWrite.cpp b/dom/serviceworkers/test/gtest/TestReadWrite.cpp index 823647d22e..66b966f9e2 100644 --- a/dom/serviceworkers/test/gtest/TestReadWrite.cpp +++ b/dom/serviceworkers/test/gtest/TestReadWrite.cpp @@ -219,7 +219,7 @@ TEST(ServiceWorkerRegistrar, TestReadData) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -280,30 +280,24 @@ TEST(ServiceWorkerRegistrar, TestWriteData) { RefPtr<ServiceWorkerRegistrarTest> swr = new ServiceWorkerRegistrarTest; - for (int i = 0; i < 2; ++i) { - ServiceWorkerRegistrationData reg; - - reg.scope() = nsPrintfCString("https://scope_write_%d.org", i); - reg.currentWorkerURL() = nsPrintfCString("currentWorkerURL write %d", i); - reg.currentWorkerHandlesFetch() = true; - reg.cacheName() = - NS_ConvertUTF8toUTF16(nsPrintfCString("cacheName write %d", i)); - reg.updateViaCache() = - nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_IMPORTS; + ServiceWorkerRegistrationData reg; - reg.currentWorkerInstalledTime() = PR_Now(); - reg.currentWorkerActivatedTime() = PR_Now(); - reg.lastUpdateTime() = PR_Now(); + reg.scope() = "https://scope_write_0.org"_ns; + reg.currentWorkerURL() = "currentWorkerURL write 0"_ns; + reg.currentWorkerHandlesFetch() = true; + reg.cacheName() = u"cacheName write 0"_ns; + reg.updateViaCache() = + nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_IMPORTS; - nsAutoCString spec; - spec.AppendPrintf("spec write %d", i); + reg.currentWorkerInstalledTime() = PR_Now(); + reg.currentWorkerActivatedTime() = PR_Now(); + reg.lastUpdateTime() = PR_Now(); - reg.principal() = mozilla::ipc::ContentPrincipalInfo( - mozilla::OriginAttributes(i % 2), spec, spec, mozilla::Nothing(), - spec); + const auto spec = "spec write 0"_ns; + reg.principal() = mozilla::ipc::ContentPrincipalInfo( + mozilla::OriginAttributes(), spec, spec, mozilla::Nothing(), spec); - swr->TestRegisterServiceWorker(reg); - } + swr->TestRegisterServiceWorker(reg); nsresult rv = swr->TestWriteData(); ASSERT_EQ(NS_OK, rv) << "WriteData() should not fail"; @@ -314,47 +308,37 @@ TEST(ServiceWorkerRegistrar, TestWriteData) nsresult rv = swr->TestReadData(); ASSERT_EQ(NS_OK, rv) << "ReadData() should not fail"; - const nsTArray<ServiceWorkerRegistrationData>& data = swr->TestGetData(); - ASSERT_EQ((uint32_t)2, data.Length()) << "2 entries should be found"; - - for (int i = 0; i < 2; ++i) { - nsAutoCString test; - - ASSERT_EQ(data[i].principal().type(), - mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); - const mozilla::ipc::ContentPrincipalInfo& cInfo = data[i].principal(); + const nsTArray<ServiceWorkerRegistrationData>& dataArr = swr->TestGetData(); + ASSERT_EQ((uint32_t)1, dataArr.Length()) << "1 entries should be found"; - mozilla::OriginAttributes attrs(i % 2); - nsAutoCString suffix, expectSuffix; - attrs.CreateSuffix(expectSuffix); - cInfo.attrs().CreateSuffix(suffix); + const auto& data = dataArr[0]; - ASSERT_STREQ(expectSuffix.get(), suffix.get()); + ASSERT_EQ(data.principal().type(), + mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); + const mozilla::ipc::ContentPrincipalInfo& cInfo = data.principal(); - test.AppendPrintf("https://scope_write_%d.org", i); - ASSERT_STREQ(test.get(), cInfo.spec().get()); + mozilla::OriginAttributes attrs; + nsAutoCString suffix, expectSuffix; + attrs.CreateSuffix(expectSuffix); + cInfo.attrs().CreateSuffix(suffix); - test.Truncate(); - test.AppendPrintf("https://scope_write_%d.org", i); - ASSERT_STREQ(test.get(), data[i].scope().get()); + ASSERT_STREQ(expectSuffix.get(), suffix.get()); - test.Truncate(); - test.AppendPrintf("currentWorkerURL write %d", i); - ASSERT_STREQ(test.get(), data[i].currentWorkerURL().get()); + ASSERT_STREQ("https://scope_write_0.org", cInfo.spec().get()); + ASSERT_STREQ("https://scope_write_0.org", data.scope().get()); + ASSERT_STREQ("currentWorkerURL write 0", data.currentWorkerURL().get()); - ASSERT_EQ(true, data[i].currentWorkerHandlesFetch()); + ASSERT_EQ(true, data.currentWorkerHandlesFetch()); - test.Truncate(); - test.AppendPrintf("cacheName write %d", i); - ASSERT_STREQ(test.get(), NS_ConvertUTF16toUTF8(data[i].cacheName()).get()); + ASSERT_STREQ("cacheName write 0", + NS_ConvertUTF16toUTF8(data.cacheName()).get()); - ASSERT_EQ(nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_IMPORTS, - data[i].updateViaCache()); + ASSERT_EQ(nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_IMPORTS, + data.updateViaCache()); - ASSERT_NE((int64_t)0, data[i].currentWorkerInstalledTime()); - ASSERT_NE((int64_t)0, data[i].currentWorkerActivatedTime()); - ASSERT_NE((int64_t)0, data[i].lastUpdateTime()); - } + ASSERT_NE((int64_t)0, data.currentWorkerInstalledTime()); + ASSERT_NE((int64_t)0, data.currentWorkerActivatedTime()); + ASSERT_NE((int64_t)0, data.lastUpdateTime()); } TEST(ServiceWorkerRegistrar, TestVersion2Migration) @@ -394,7 +378,7 @@ TEST(ServiceWorkerRegistrar, TestVersion2Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -464,7 +448,7 @@ TEST(ServiceWorkerRegistrar, TestVersion3Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -532,7 +516,7 @@ TEST(ServiceWorkerRegistrar, TestVersion4Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -604,7 +588,7 @@ TEST(ServiceWorkerRegistrar, TestVersion5Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -678,7 +662,7 @@ TEST(ServiceWorkerRegistrar, TestVersion6Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -765,7 +749,7 @@ TEST(ServiceWorkerRegistrar, TestVersion7Migration) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -850,7 +834,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeRead) nsAutoCString suffix0; cInfo0.attrs().CreateSuffix(suffix0); - ASSERT_STREQ("^inBrowser=1", suffix0.get()); + ASSERT_STREQ("", suffix0.get()); ASSERT_STREQ("https://scope_0.org", cInfo0.spec().get()); ASSERT_STREQ("https://scope_0.org", data[0].scope().get()); ASSERT_STREQ("currentWorkerURL 0", data[0].currentWorkerURL().get()); @@ -903,8 +887,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite) spec.AppendPrintf("spec write dedupe/%d", i); reg.principal() = mozilla::ipc::ContentPrincipalInfo( - mozilla::OriginAttributes(false), spec, spec, mozilla::Nothing(), - spec); + mozilla::OriginAttributes(), spec, spec, mozilla::Nothing(), spec); swr->TestRegisterServiceWorker(reg); } @@ -926,7 +909,7 @@ TEST(ServiceWorkerRegistrar, TestDedupeWrite) mozilla::ipc::PrincipalInfo::TContentPrincipalInfo); const mozilla::ipc::ContentPrincipalInfo& cInfo = data[0].principal(); - mozilla::OriginAttributes attrs(false); + mozilla::OriginAttributes attrs; nsAutoCString suffix, expectSuffix; attrs.CreateSuffix(expectSuffix); cInfo.attrs().CreateSuffix(suffix); diff --git a/dom/serviceworkers/test/test_serviceworker_interfaces.js b/dom/serviceworkers/test/test_serviceworker_interfaces.js index 1cf0896edf..c13c228d71 100644 --- a/dom/serviceworkers/test/test_serviceworker_interfaces.js +++ b/dom/serviceworkers/test/test_serviceworker_interfaces.js @@ -1,3 +1,5 @@ +/* eslint-disable mozilla/no-comparison-or-assignment-inside-ok */ + // This is a list of all interfaces that are exposed to workers. // Please only add things to this list with great care and proper review // from the associated module peers. @@ -173,8 +175,6 @@ let interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! "DOMRectReadOnly", // IMPORTANT: Do not change this list without review from a DOM peer! - { name: "DOMRequest", disabled: true }, - // IMPORTANT: Do not change this list without review from a DOM peer! "DOMStringList", // IMPORTANT: Do not change this list without review from a DOM peer! "ErrorEvent", |