t2ym / thin-hook

Thin Hook Preprocessor
Other
4 stars 1 forks source link

[demo][normalize.js] TypeError: Illegal invocation for window property within "with" statement on Object.create(window) #415

Closed t2ym closed 2 years ago

t2ym commented 2 years ago

[demo][normalize.js] TypeError: Illegal invocation for window property within with statement on Object.create(window)

Root Cause

Reproducible Code

  with (Object.create(window)) {
    chai.assert.throws(() => {
      caches;
    }, /^Permission Denied:/);

    chai.assert.throws(() => {
      Object.getOwnPropertyDescriptor(window, 'caches'); // access to window is illegal
    }, /^Permission Denied:/);
  }

Fix