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

mark scripts as shareable cross-origin #25380

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
9 participants
@nornagon
Copy link
Contributor

nornagon commented Jan 7, 2019

This fixes an issue in Electron where errors were being incorrectly sanitized on their way to window.onerror. e.g.

process.nextTick(() => throw new Error('hi'))
window.onerror = e => console.log(e)

was printing "Script error" instead of "Uncaught Error: hi"

This is due to origin-checking logic in Blink: https://chromium.googlesource.com/chromium/src/+/71.0.3578.123/third_party/blink/renderer/core/execution_context/execution_context.cc#114

cc @joyeecheung who is blame on a lot of this code :)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@nornagon

This comment has been minimized.

Copy link
Contributor Author

nornagon commented Jan 7, 2019

To clarify, I'm not 100% sure this is the right approach (perhaps Electron should somehow be injecting a correct origin for these scripts?) but it does fix the issue and I'm not aware of the context for deciding to mark scripts as non-cross-origin-shareable in node (if any—it seems not relevant to most non-Electron node.js use cases)

@nornagon nornagon force-pushed the nornagon:script-origin branch from c3cf16c to 9a21126 Jan 7, 2019

Show resolved Hide resolved src/module_wrap.cc Outdated
@cjihrig

This comment has been minimized.

Copy link
Contributor

cjihrig commented Jan 7, 2019

Ping @nodejs/v8. The code changes themselves LGTM, but someone more knowledgeable about V8 should weigh in. From a quick search of the codebase, IsSharedCrossOrigin() appears to be unused by Node and V8, so maybe it's not relevant to anything but browsers.

@nornagon nornagon force-pushed the nornagon:script-origin branch from 9a21126 to 98214ca Jan 8, 2019

@nornagon

This comment has been minimized.

Copy link
Contributor Author

nornagon commented Jan 8, 2019

Whitespace tidied.

@joyeecheung
Copy link
Member

joyeecheung left a comment

LGTM. I also did this when trying to fix #11893 (but that patch involved something more breaking than this)

@ryzokuken
Copy link
Member

ryzokuken left a comment

LGTM. 😉

@hashseed

This comment has been minimized.

Copy link
Member

hashseed commented Jan 8, 2019

Yes. This really is just a bit set for the browser. LGTM.

@cjihrig

cjihrig approved these changes Jan 8, 2019

@antsmartian

This comment has been minimized.

Copy link
Contributor

antsmartian commented Jan 8, 2019

@jasnell

jasnell approved these changes Jan 8, 2019

@nornagon

This comment has been minimized.

Copy link
Contributor Author

nornagon commented Jan 8, 2019

looks to me like the test failures are flakes?

@addaleax

This comment has been minimized.

Copy link
Member

addaleax commented Jan 14, 2019

@addaleax

This comment has been minimized.

Copy link
Member

addaleax commented Jan 28, 2019

Landed in 817218c, thanks for the PR!

@addaleax addaleax closed this Jan 28, 2019

pull bot pushed a commit to zys-contribs/node that referenced this pull request Jan 28, 2019

vm: mark scripts as shareable cross-origin
PR-URL: nodejs#25380
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit that referenced this pull request Jan 28, 2019

vm: mark scripts as shareable cross-origin
PR-URL: #25380
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@targos targos referenced this pull request Jan 29, 2019

Merged

v11.9.0 proposal #25802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment