Bug 1904124 - Part 1: Move all notification related tests to dom/notification/test/ r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D215219
This commit is contained in:
Kagami Sascha Rosylight 2024-07-01 20:13:31 +00:00
Родитель 2e0d690651
Коммит 827569375b
42 изменённых файлов: 134 добавлений и 94 удалений

Просмотреть файл

@ -2,3 +2,9 @@
["browser_permission_dismiss.js"]
support-files = ["notification.html"]
["browser_userContextId_openWindow.js"]
support-files = [
"empty.html",
"file_userContextId_openWindow.js",
]

Просмотреть файл

@ -4,8 +4,10 @@ let swm = Cc["@mozilla.org/serviceworkers/manager;1"].getService(
Ci.nsIServiceWorkerManager
);
const URI = "https://example.com/browser/dom/serviceworkers/test/empty.html";
const URI =
"https://example.com/browser/dom/notification/test/browser/empty.html";
const MOCK_CID = Components.ID("{2a0f83c4-8818-4914-a184-f1172b4eaaa7}");
const SYSTEM_CID = Components.ID("{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}");
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
const USER_CONTEXT_ID = 3;
@ -39,10 +41,9 @@ let mockAlertsService = {
};
registerCleanupFunction(() => {
Cm.QueryInterface(Ci.nsIComponentRegistrar).unregisterFactory(
MOCK_CID,
mockAlertsService
);
const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(MOCK_CID, mockAlertsService);
registrar.registerFactory(SYSTEM_CID, "", ALERTS_SERVICE_CONTRACT_ID, null);
});
add_setup(async function () {

Просмотреть файл

@ -20,6 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090
<![CDATA[
/** Test for Bug 874090 **/
const MOCK_CID = Components.ID("{2a0f83c4-8818-4914-a184-f1172b4eaaa7}");
const SYSTEM_CID = Components.ID("{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}");
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
var mockAlertsService = {
@ -46,8 +47,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090
}
function unregisterMock() {
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
unregisterFactory(MOCK_CID, mockAlertsService);
const registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(MOCK_CID, mockAlertsService);
registrar.registerFactory(SYSTEM_CID, "", ALERTS_SERVICE_CONTRACT_ID, null);
}
function runTests() {

Просмотреть файл

@ -8,6 +8,7 @@ function mockServicesChromeScript() {
const MOCK_ALERTS_CID = Components.ID(
"{48068bc2-40ab-4904-8afd-4cdfb3a385f3}"
);
const SYSTEM_CID = Components.ID("{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}");
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
const { setTimeout } = ChromeUtils.importESModule(
@ -116,6 +117,8 @@ function mockServicesChromeScript() {
closeAllNotifications();
activeNotifications = null;
registrar.unregisterFactory(MOCK_ALERTS_CID, mockAlertsService);
// Revive the system one
registrar.registerFactory(SYSTEM_CID, "", ALERTS_SERVICE_CONTRACT_ID, null);
sendAsyncMessage("mock-alert-service:unregistered");
});

Просмотреть файл

@ -1,8 +1,6 @@
[DEFAULT]
support-files = [
"blank.html",
"create_notification.html",
"MockAlertsService.js",
"NotificationTest.js",
]
@ -15,6 +13,7 @@ skip-if = [
]
["test_notification_crossorigin_iframe.html"]
support-files = ["blank.html"]
scheme = "https"
# This test needs to be run on HTTP (not HTTPS).
@ -25,10 +24,103 @@ skip-if = [
]
["test_notification_permissions.html"]
support-files = ["blank.html"]
scheme = "https"
["test_notification_serviceworker_constructor_error.html"]
support-files = ["notification_constructor_error.js"]
["test_notification_serviceworker_get.html"]
skip-if = ["xorigin"] # Bug 1792790
support-files = [
"notification_get_sw.js",
"notification/register.html",
]
["test_notification_serviceworker_openWindow_nested.html"]
skip-if = [
"os == 'android'", # Bug 1620052
"xorigin", # Bug 1792790
"condprof", #: timed out
"http3",
"http2",
]
support-files = [
"openWindow_worker.js",
"open_window/client.sjs",
"redirect.sjs",
"!/dom/serviceworkers/test/utils.js",
]
tags = "openwindow"
["test_notification_serviceworker_openWindow.html"]
skip-if = [
"os == 'android'", # Bug 1620052
"xorigin", # JavaScript error: http://mochi.xorigin-test:8888/tests/SimpleTest/TestRunner.js, line 157: SecurityError: Permission denied to access property "wrappedJSObject" on cross-origin object
"http3",
"http2",
]
support-files = [
"notification_openWindow_worker.js",
"file_notification_openWindow.html",
"!/dom/serviceworkers/test/utils.js",
]
tags = "openwindow"
["test_notification_worker_child.html"]
skip-if = [
"os == 'android'", # Bug 1816427, Notification.onshow/close are broken on Android
]
support-files = [
"notification_worker_child-child.js",
"notification_worker_child-parent.js",
]
["test_notification_worker_permission.html"]
support-files = ["notification_permission_worker.js"]
["test_notification_worker.html"]
skip-if = [
"os == 'android'", # Bug 1816427, Notification.onshow/close are broken on Android
]
support-files = ["notification_worker.js"]
["test_notificationclick_focus.html"]
skip-if = ["xorigin"] # Bug 1792790
support-files = [
"notificationclick_focus.html",
"notificationclick_focus.js",
"!/dom/serviceworkers/test/utils.js",
]
["test_notificationclick_otherwindow.html"]
skip-if = ["xorigin"] # Bug 1792790
support-files = [
"notificationclick-otherwindow.html",
"notificationclick.js",
"!/dom/serviceworkers/test/utils.js",
]
["test_notificationclick.html"]
skip-if = ["xorigin"] # Bug 1792790
support-files = [
"notificationclick.html",
"notificationclick.js",
"!/dom/serviceworkers/test/utils.js",
]
["test_notificationclose.html"]
skip-if = ["xorigin"] # Bug 1792790
support-files = [
"blank.html",
"notificationclose.html",
"notificationclose.js",
"!/dom/serviceworkers/test/utils.js",
]
["test_notification_tag.html"]
skip-if = [
"http3",
"http2",
]
support-files = ["create_notification.html"]

Просмотреть файл

Просмотреть файл

@ -1,5 +1,5 @@
const gRoot = "http://mochi.test:8888/tests/dom/serviceworkers/test/";
const gTestURL = gRoot + "test_notification_openWindow.html";
const gRoot = "http://mochi.test:8888/tests/dom/notification/test/mochitest/";
const gTestURL = gRoot + "test_notification_serviceworker_openWindow.html";
const gClientURL = gRoot + "file_notification_openWindow.html";
onmessage = function (event) {

Просмотреть файл

@ -5,7 +5,7 @@ onnotificationclose = function (e) {
e.waitUntil(
(async function () {
let windowOpened = true;
await clients.openWindow("hello.html").catch(err => {
await clients.openWindow("blank.html").catch(err => {
windowOpened = false;
});

Просмотреть файл

@ -114,13 +114,13 @@ onnotificationclick = function (e) {
var promises = [];
var redirect =
"http://mochi.test:8888/tests/dom/serviceworkers/test/redirect.sjs?";
"http://mochi.test:8888/tests/dom/notification/test/mochitest/redirect.sjs?";
var redirect_xorigin =
"http://example.com/tests/dom/serviceworkers/test/redirect.sjs?";
"http://example.com/tests/dom/notification/test/mochitest/redirect.sjs?";
var same_origin =
"http://mochi.test:8888/tests/dom/serviceworkers/test/open_window/client.sjs";
"http://mochi.test:8888/tests/dom/notification/test/mochitest/open_window/client.sjs";
var different_origin =
"http://example.com/tests/dom/serviceworkers/test/open_window/client.sjs";
"http://example.com/tests/dom/notification/test/mochitest/open_window/client.sjs";
promises.push(testForUrl("about:blank", "TypeError", null, results));
promises.push(testForUrl(different_origin, null, null, results));

Просмотреть файл

@ -39,7 +39,7 @@ const RESPONSE = `
}
var iframe = document.createElement('iframe');
iframe.src = "http://mochi.test:8888/tests/dom/serviceworkers/test/open_window/client.sjs";
iframe.src = "http://mochi.test:8888/tests/dom/notification/test/mochitest/open_window/client.sjs";
document.body.appendChild(iframe);
}
}

Просмотреть файл

@ -0,0 +1,4 @@
function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, 301, "Moved Permanently");
response.setHeader("Location", request.queryString, false);
}

Просмотреть файл

@ -3,7 +3,7 @@
<head>
<title>Bug 1578070</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript" src="/tests/dom/notification/test/mochitest/MockAlertsService.js"></script>
<script type="text/javascript" src="/tests/dom/notification/test/mochitest/NotificationTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />

Просмотреть файл

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1172870
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");
@ -103,6 +103,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1172870
["dom.serviceWorkers.idle_timeout", 299999],
["dom.serviceWorkers.idle_extended_timeout", 299999],
["dom.securecontext.allowlist", "mochi.test,example.com"],
["network.cookie.cookieBehavior", 0], // XXX: Doesn't work with dFPI
]}, runTest);
</script>
</body>

Просмотреть файл

@ -27,6 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=782211
function mockServicesChromeScript() {
/* eslint-env mozilla/chrome-script */
const MOCK_CID = Components.ID("{dbe37e64-d9a3-402c-8d8a-0826c619f7ad}");
const SYSTEM_CID = Components.ID("{a0ccaaf8-09da-44d8-b250-9ac3e93c8117}");
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
var notificationsCreated = [];
@ -66,6 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=782211
// Register original alerts service.
registrar.unregisterFactory(MOCK_CID, this);
registrar.registerFactory(SYSTEM_CID, "", ALERTS_SERVICE_CONTRACT_ID, null);
sendAsyncMessage("mock-alert-service:unregistered");
}

Просмотреть файл

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916893
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");

Просмотреть файл

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916893
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");

Просмотреть файл

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916893
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");

Просмотреть файл

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265841
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script src="/tests/dom/serviceworkers/test/utils.js"></script>
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show, click, and close events.");

Просмотреть файл

@ -9,7 +9,6 @@ support-files = [
"download_canceled/server-stream-download.sjs",
"download_canceled/sw_download_canceled.js",
"fetch.js",
"file_userContextId_openWindow.js",
"force_refresh_browser_worker.js",
"ForceRefreshChild.sys.mjs",
"ForceRefreshParent.sys.mjs",
@ -59,5 +58,3 @@ skip-if = ["true"] # Crashes: @ mozilla::dom::ServiceWorkerManagerService::Propa
["browser_storage_recovery.js"]
["browser_unregister_with_containers.js"]
["browser_userContextId_openWindow.js"]

Просмотреть файл

@ -116,21 +116,11 @@ support-files = [
"bug1151916_worker.js",
"bug1151916_driver.html",
"bug1240436_worker.js",
"notificationclick.html",
"notificationclick-otherwindow.html",
"notificationclick.js",
"notificationclick_focus.html",
"notificationclick_focus.js",
"notificationclose.html",
"notificationclose.js",
"worker_updatefoundevent.js",
"worker_updatefoundevent2.js",
"updatefoundevent.html",
"empty.html",
"empty.js",
"notification_constructor_error.js",
"notification_get_sw.js",
"notification/register.html",
"sanitize/frame.html",
"sanitize/register.html",
"sanitize/example_check_and_unregister.html",
@ -183,9 +173,7 @@ support-files = [
"xslt/*",
"unresolved_fetch_worker.js",
"header_checker.sjs",
"openWindow_worker.js",
"redirect.sjs",
"open_window/client.sjs",
"lorem_script.js",
"file_blob_response_worker.js",
"file_js_cache_cleanup.js",
@ -350,36 +338,6 @@ skip-if = ["os == 'linux' && bits == 64 && debug"] # Bug 1749068
["test_not_intercept_plugin.html"]
skip-if = ["serviceworker_e10s"] # leaks InterceptedHttpChannel and others things
["test_notification_constructor_error.html"]
["test_notification_get.html"]
skip-if = ["xorigin"] # Bug 1792790
["test_notification_openWindow.html"]
skip-if = [
"os == 'android'", # Bug 1620052
"xorigin", # JavaScript error: http://mochi.xorigin-test:8888/tests/SimpleTest/TestRunner.js, line 157: SecurityError: Permission denied to access property "wrappedJSObject" on cross-origin object
"http3",
"http2",
]
support-files = [
"notification_openWindow_worker.js",
"file_notification_openWindow.html",
]
tags = "openwindow"
["test_notificationclick-otherwindow.html"]
skip-if = ["xorigin"] # Bug 1792790
["test_notificationclick.html"]
skip-if = ["xorigin"] # Bug 1792790
["test_notificationclick_focus.html"]
skip-if = ["xorigin"] # Bug 1792790
["test_notificationclose.html"]
skip-if = ["xorigin"] # Bug 1792790
["test_onmessageerror.html"]
skip-if = ["xorigin"] # Bug 1792790

Просмотреть файл

@ -39,16 +39,6 @@ skip-if = ["condprof"] #: timed out
["test_importscript_mixedcontent.html"]
tags = "mcb"
["test_openWindow.html"]
skip-if = [
"os == 'android'", # Bug 1620052
"xorigin", # Bug 1792790
"condprof", #: timed out
"http3",
"http2",
]
tags = "openwindow"
["test_sanitize_domain.html"]
skip-if = [
"http3",

Просмотреть файл

@ -50,10 +50,6 @@ support-files = [
"navigator_languages_worker.js",
"navigator_worker.js",
"newError_worker.js",
"notification_worker.js",
"notification_worker_child-child.js",
"notification_worker_child-parent.js",
"notification_permission_worker.js",
"onLine_worker.js",
"onLine_worker_child.js",
"onLine_worker_head.js",
@ -280,18 +276,6 @@ support-files = [
["test_newError.html"]
["test_notification.html"]
skip-if = [
"os == 'android'", # Bug 1816427, Notification.onshow/close are broken on Android
]
["test_notification_child.html"]
skip-if = [
"os == 'android'", # Bug 1816427, Notification.onshow/close are broken on Android
]
["test_notification_permission.html"]
["test_onLine.html"]
["test_promise.html"]