Rename option to contextIsolation

This commit is contained in:
Kevin Sawicki 2016-12-15 13:20:17 -08:00
parent b56bdc83af
commit ad3b837ad5
5 changed files with 20 additions and 15 deletions

View file

@ -121,8 +121,9 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
// Run Electron APIs and preload script in isolated world // Run Electron APIs and preload script in isolated world
bool isolated; bool isolated;
if (web_preferences.GetBoolean("isolated", &isolated) && isolated) if (web_preferences.GetBoolean(options::kContextIsolation, &isolated) &&
command_line->AppendSwitch(switches::kIsolatedWorld); isolated)
command_line->AppendSwitch(switches::kContextIsolation);
// --background-color. // --background-color.
std::string color; std::string color;

View file

@ -99,6 +99,9 @@ const char kPreloadURL[] = "preloadURL";
// Enable the node integration. // Enable the node integration.
const char kNodeIntegration[] = "nodeIntegration"; const char kNodeIntegration[] = "nodeIntegration";
// Enable context isolation of Electron APIs and preload script
const char kContextIsolation[] = "contextIsolation";
// Instancd ID of guest WebContents. // Instancd ID of guest WebContents.
const char kGuestInstanceID[] = "guestInstanceId"; const char kGuestInstanceID[] = "guestInstanceId";
@ -163,7 +166,7 @@ const char kZoomFactor[] = "zoom-factor";
const char kPreloadScript[] = "preload"; const char kPreloadScript[] = "preload";
const char kPreloadURL[] = "preload-url"; const char kPreloadURL[] = "preload-url";
const char kNodeIntegration[] = "node-integration"; const char kNodeIntegration[] = "node-integration";
const char kIsolatedWorld[] = "isolated-world"; const char kContextIsolation[] = "context-isolation";
const char kGuestInstanceID[] = "guest-instance-id"; const char kGuestInstanceID[] = "guest-instance-id";
const char kOpenerID[] = "opener-id"; const char kOpenerID[] = "opener-id";
const char kScrollBounce[] = "scroll-bounce"; const char kScrollBounce[] = "scroll-bounce";

View file

@ -54,6 +54,7 @@ extern const char kZoomFactor[];
extern const char kPreloadScript[]; extern const char kPreloadScript[];
extern const char kPreloadURL[]; extern const char kPreloadURL[];
extern const char kNodeIntegration[]; extern const char kNodeIntegration[];
extern const char kContextIsolation[];
extern const char kGuestInstanceID[]; extern const char kGuestInstanceID[];
extern const char kExperimentalFeatures[]; extern const char kExperimentalFeatures[];
extern const char kExperimentalCanvasFeatures[]; extern const char kExperimentalCanvasFeatures[];
@ -86,7 +87,7 @@ extern const char kZoomFactor[];
extern const char kPreloadScript[]; extern const char kPreloadScript[];
extern const char kPreloadURL[]; extern const char kPreloadURL[];
extern const char kNodeIntegration[]; extern const char kNodeIntegration[];
extern const char kIsolatedWorld[]; extern const char kContextIsolation[];
extern const char kGuestInstanceID[]; extern const char kGuestInstanceID[];
extern const char kOpenerID[]; extern const char kOpenerID[];
extern const char kScrollBounce[]; extern const char kScrollBounce[];

View file

@ -163,7 +163,7 @@ AtomRendererClient::AtomRendererClient()
: node_bindings_(NodeBindings::Create(false)), : node_bindings_(NodeBindings::Create(false)),
atom_bindings_(new AtomBindings) { atom_bindings_(new AtomBindings) {
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch( isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kIsolatedWorld); switches::kContextIsolation);
// Parse --standard-schemes=scheme1,scheme2 // Parse --standard-schemes=scheme1,scheme2
std::vector<std::string> standard_schemes_list = std::vector<std::string> standard_schemes_list =
ParseSchemesCLISwitch(switches::kStandardSchemes); ParseSchemesCLISwitch(switches::kStandardSchemes);

View file

@ -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) => { it('separates the page context from the Electron/preload context', (done) => {
if (w != null) w.destroy() if (w != null) w.destroy()
@ -1860,7 +1860,7 @@ describe('BrowserWindow module', function () {
w = new BrowserWindow({ w = new BrowserWindow({
show: false, show: false,
webPreferences: { webPreferences: {
isolated: true, contextIsolation: true,
preload: path.join(fixtures, 'api', 'isolated-preload.js') preload: path.join(fixtures, 'api', 'isolated-preload.js')
} }
}) })