Bug 1922020, part 9 - Remove reliance on window.opener storage access heuristic in user.js from dom/notification - r=saschanaz

I simply gave up here because I don't know what the correct behavior we should test for in a partitioned worker is.

The heuristic was making the xorigin test work because the window open would force the iframe into a non-partitioned state

Differential Revision: https://phabricator.services.mozilla.com/D224814
This commit is contained in:
Benjamin VanderSloot 2024-11-04 20:38:38 +00:00
parent 67b11bf553
commit 3201bf6536
5 changed files with 47 additions and 11 deletions

View File

@ -61,13 +61,26 @@ if (self.Notification) {
// store notification in test context
this.notification = notification;
notification.onshow = function () {
ok(true, "onshow handler should be called");
done();
};
if (self.location.search == "?xorigin") {
notification.onerror = function () {
ok(true, "onshow handler should be called");
done();
};
} else {
notification.onshow = function () {
ok(true, "onshow handler should be called");
done();
};
}
},
function (done) {
if (self.location.search == "?xorigin") {
ok(true, "onclose handler can not be called in partitioned workers");
done();
return;
}
var notification = this.notification;
notification.onclose = function () {

View File

@ -50,15 +50,28 @@ if (self.Notification) {
// store notification in test context
this.notification = notification;
notification.onshow = function () {
ok(true, "onshow handler should be called");
done();
};
if (self.location.search == "?xorigin") {
notification.onerror = function () {
ok(true, "onshow handler should be called");
done();
};
} else {
notification.onshow = function () {
ok(true, "onshow handler should be called");
done();
};
}
},
function (done) {
var notification = this.notification;
if (self.location.search == "?xorigin") {
ok(true, "onclose handler can not be called in partitioned workers");
done();
return;
}
notification.onclose = function () {
ok(true, "onclose handler should be called");
done();

View File

@ -7,7 +7,9 @@ function is(a, b, message) {
}
if (self.Notification) {
var child = new Worker("notification_worker_child-child.js");
var child = new Worker(
"notification_worker_child-child.js" + self.location.search
);
child.onerror = function (e) {
ok(false, "Error loading child worker " + e);
postMessage({ type: "finish" });

View File

@ -20,7 +20,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916893
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events.");
async function runTest() {
var w = new Worker("notification_worker.js");
let workerPath = "notification_worker.js";
if (isXOrigin) {
workerPath += "?xorigin";
}
var w = new Worker(workerPath);
w.onmessage = function(e) {
if (e.data.type === 'finish') {
SimpleTest.finish();

View File

@ -19,7 +19,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916893
<script type="text/javascript">
SimpleTest.requestFlakyTimeout("Mock alert service dispatches show event.");
async function runTest() {
var w = new Worker("notification_worker_child-parent.js");
let workerPath = "notification_worker_child-parent.js";
if (isXOrigin) {
workerPath += "?xorigin";
}
var w = new Worker(workerPath);
w.onmessage = function(e) {
if (e.data.type === 'finish') {
SimpleTest.finish();