From 225a0197435f3ada2b1170d59c323f80ea860731 Mon Sep 17 00:00:00 2001 From: Spencer Elliott Date: Fri, 21 Aug 2015 20:19:31 -0400 Subject: [PATCH] Replace applescript with browser-launcher2 This allows... 1. launching Chrome on platforms other than OS X 2. users to launch their own instance of Chrome (e.g. via command line) rather than being forced to use the default instance (i.e. `tell application "Chrome"` always used the default instance) `isDebuggerConnected()` addresses the problem in #510 where the dev tools would only open once per server session. Add a '--dangerouslyDisableChromeDebuggerWebSecurity' flag to packager.js to enable Chrome '--disable-web-security' flag. This allows users to inspect network requests in Chrome by commenting the xhr polyfill in InitializeJavaScriptAppEngine.js: https://github.com/facebook/react-native/issues/934#issuecomment-94525104 Usage: node packager.js --dangerouslyDisableChromeDebuggerWebSecurity or: packager.sh --dangerouslyDisableChromeDebuggerWebSecurity --- packager/packager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packager/packager.js b/packager/packager.js index 0f93a3306fd033..a3487df033be50 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -65,6 +65,9 @@ var options = parseCommandLine([{ type: 'string', default: require.resolve('./transformer.js'), description: 'Specify a custom transformer to be used (absolute path)' +}, { + command: 'dangerouslyDisableChromeDebuggerWebSecurity', + description: 'Disable the Chrome debugger\'s same-origin policy' }]); if (options.projectRoots) { @@ -199,6 +202,10 @@ function getDevToolsLauncher(options) { return; } var debuggerURL = 'http://localhost:' + options.port + '/debugger-ui'; + var chromeOptions = + options.dangerouslyDisableChromeDebuggerWebSecurity ? + ['--disable-web-security'] : + []; console.log('Launching Dev Tools...'); launcher(function(err, launch) { if (err) { @@ -207,6 +214,7 @@ function getDevToolsLauncher(options) { } launch(debuggerURL, { browser: 'chrome', + options: chromeOptions, }, function(err, instance) { if (err) { console.error('Failed to launch chrome', err);