mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
fix some serviceworker methods
This commit is contained in:
parent
243028483e
commit
a8d2784e80
2 changed files with 23 additions and 0 deletions
|
@ -11,6 +11,8 @@ export default function (client: ScramjetClient) {
|
|||
|
||||
const realwin = ctx.fn.apply(ctx.this, ctx.args);
|
||||
|
||||
if (!realwin) return ctx.return(realwin);
|
||||
|
||||
if (ScramjetClient.SCRAMJET in realwin.self) {
|
||||
return ctx.return(realwin.self[ScramjetClient.SCRAMJET].windowProxy);
|
||||
} else {
|
||||
|
|
|
@ -38,6 +38,24 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
},
|
||||
});
|
||||
|
||||
client.Proxy("navigator.serviceWorker.getRegistrations", {
|
||||
apply(ctx) {
|
||||
ctx.return(new Promise((resolve) => resolve([registration])));
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("navigator.serviceWorker.ready", {
|
||||
get(ctx) {
|
||||
return new Promise((resolve) => resolve(registration));
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("navigator.serviceWorker.controller", {
|
||||
get(ctx) {
|
||||
return registration.active;
|
||||
},
|
||||
});
|
||||
|
||||
client.Proxy("navigator.serviceWorker.register", {
|
||||
apply(ctx) {
|
||||
if (ctx.args[0] instanceof URL) ctx.args[0] = ctx.args[0].href;
|
||||
|
@ -77,6 +95,9 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
if (prop === "scope") {
|
||||
return ctx.args[0];
|
||||
}
|
||||
if (prop === "unregister") {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
if (prop === "addEventListener") {
|
||||
return () => {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue