diff options
Diffstat (limited to 'dom/serviceworkers/test')
8 files changed, 59 insertions, 66 deletions
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", |