New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PushSubscriptionOptions ArrayBuffer lifetime issues #198
Comments
|
I was wondering if serviceWorkerRegistration.pushManager.getSubscription().then(subscription => {
let applicationServerKey = subscription.options.applicationServerKey;
let keyArray = new Uint8Array(applicationServerKey);
keyArray[0] = 123;
let maybeModifiedKey = subscription.options.applicationServerKey;
// If `applicationServerKey` is `[SameObject]`, does that mean scripts could
// change the contents of the key?
assert(applicationServerKey == modifiedKey);
assert(new Uint8Array(maybeModifiedKey)[0] == 123);
return serviceWorkerRegistration.pushManager.getSubscription().then(newSubscription => {
// `getSubscription` resolves to a new `PushSubscription` instance, so I assume
// these are all true. Is that right?
assert(newSubscription != subscription);
assert(newSubscription.applicationServerKey != applicationServerKey);
assert(new Uint8Array(newSubscription.applicationServerKey)[0] != 123);
});
}); ("Don't do that" is an acceptable answer for the first, but I'm curious how specs handle this kind of thing). |
The other object being mutated is immaterial to that. If you want to support multiple consumers that cannot accidentally confuse each other you would need to use a method instead that returns copies from some internal state. |
The Since Thanks all - I'll send out a PR to replace |
PushSubscriptionOptions is spec'd as:
[Throws]
do? I couldn't find it in WebIDL - is it Mozilla-specific IDL syntax?==
comparison?transfer
argument to postMessage (or usingArrayBuffer.transfer()
)? Do we need to freeze it or something like that? Would freezing even have any effect, since the data being detached is stored in an internal slot? See also w3c issue 23369. For example I noticed that @annevk used[NewObject]
for https://encoding.spec.whatwg.org/#textencoder, but we probably can't use that here since[NewObject]
is only for methods, not for attributes.@martinthomson @beverloo
The text was updated successfully, but these errors were encountered: