diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 300c2b88ae09..d5bde07250e6 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -121,8 +121,9 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( // Run Electron APIs and preload script in isolated world bool isolated; - if (web_preferences.GetBoolean("isolated", &isolated) && isolated) - command_line->AppendSwitch(switches::kIsolatedWorld); + if (web_preferences.GetBoolean(options::kContextIsolation, &isolated) && + isolated) + command_line->AppendSwitch(switches::kContextIsolation); // --background-color. std::string color; diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index cb33972dc425..f1eecdbd47c7 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -99,6 +99,9 @@ const char kPreloadURL[] = "preloadURL"; // Enable the node integration. const char kNodeIntegration[] = "nodeIntegration"; +// Enable context isolation of Electron APIs and preload script +const char kContextIsolation[] = "contextIsolation"; + // Instancd ID of guest WebContents. const char kGuestInstanceID[] = "guestInstanceId"; @@ -158,15 +161,15 @@ const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist"; const char kAppUserModelId[] = "app-user-model-id"; // The command line switch versions of the options. -const char kBackgroundColor[] = "background-color"; -const char kZoomFactor[] = "zoom-factor"; -const char kPreloadScript[] = "preload"; -const char kPreloadURL[] = "preload-url"; -const char kNodeIntegration[] = "node-integration"; -const char kIsolatedWorld[] = "isolated-world"; -const char kGuestInstanceID[] = "guest-instance-id"; -const char kOpenerID[] = "opener-id"; -const char kScrollBounce[] = "scroll-bounce"; +const char kBackgroundColor[] = "background-color"; +const char kZoomFactor[] = "zoom-factor"; +const char kPreloadScript[] = "preload"; +const char kPreloadURL[] = "preload-url"; +const char kNodeIntegration[] = "node-integration"; +const char kContextIsolation[] = "context-isolation"; +const char kGuestInstanceID[] = "guest-instance-id"; +const char kOpenerID[] = "opener-id"; +const char kScrollBounce[] = "scroll-bounce"; // Widevine options // Path to Widevine CDM binaries. diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 3ce8dadb32d6..2742d0c8259b 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -54,6 +54,7 @@ extern const char kZoomFactor[]; extern const char kPreloadScript[]; extern const char kPreloadURL[]; extern const char kNodeIntegration[]; +extern const char kContextIsolation[]; extern const char kGuestInstanceID[]; extern const char kExperimentalFeatures[]; extern const char kExperimentalCanvasFeatures[]; @@ -86,7 +87,7 @@ extern const char kZoomFactor[]; extern const char kPreloadScript[]; extern const char kPreloadURL[]; extern const char kNodeIntegration[]; -extern const char kIsolatedWorld[]; +extern const char kContextIsolation[]; extern const char kGuestInstanceID[]; extern const char kOpenerID[]; extern const char kScrollBounce[]; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 2e51eb539d18..78027008373d 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -163,7 +163,7 @@ AtomRendererClient::AtomRendererClient() : node_bindings_(NodeBindings::Create(false)), atom_bindings_(new AtomBindings) { isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kIsolatedWorld); + switches::kContextIsolation); // Parse --standard-schemes=scheme1,scheme2 std::vector standard_schemes_list = ParseSchemesCLISwitch(switches::kStandardSchemes); diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 2dd7fc81b7b0..6332406a85b3 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1835,7 +1835,7 @@ describe('BrowserWindow module', function () { }) }) - describe('isolated option', () => { + describe('contextIsolation option', () => { it('separates the page context from the Electron/preload context', (done) => { if (w != null) w.destroy() @@ -1860,7 +1860,7 @@ describe('BrowserWindow module', function () { w = new BrowserWindow({ show: false, webPreferences: { - isolated: true, + contextIsolation: true, preload: path.join(fixtures, 'api', 'isolated-preload.js') } })