Re: [w3c/push-api] PushSubscriptionOptions ArrayBuffer lifetime issues (#198)

I was wondering if `[SameObject]` means scripts could mutate the `ArrayBuffer`, and how it behaves with two `PushSubscription` objects for the same scope. For example:

```js
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).

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/push-api/issues/198#issuecomment-230785938

Received on Wednesday, 6 July 2016 14:20:18 UTC