Merge pull request #2743 from atom/fix-backward-compatibility
Fix backward compatibility with old BrowserWindow options
This commit is contained in:
commit
e5496d9ac0
3 changed files with 29 additions and 12 deletions
|
@ -70,14 +70,13 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
|
||||||
options.Get(switches::kWebPreferences, &web_preferences);
|
options.Get(switches::kWebPreferences, &web_preferences);
|
||||||
|
|
||||||
// Be compatible with old options which are now in web_preferences.
|
// Be compatible with old options which are now in web_preferences.
|
||||||
std::string str;
|
v8::Local<v8::Value> value;
|
||||||
double d;
|
if (options.Get(switches::kNodeIntegration, &value))
|
||||||
if (options.Get(switches::kNodeIntegration, &str))
|
web_preferences.Set(switches::kNodeIntegration, value);
|
||||||
web_preferences.Set(switches::kNodeIntegration, str);
|
if (options.Get(switches::kPreloadScript, &value))
|
||||||
if (options.Get(switches::kPreloadScript, &str))
|
web_preferences.Set(switches::kPreloadScript, value);
|
||||||
web_preferences.Set(switches::kPreloadScript, str);
|
if (options.Get(switches::kZoomFactor, &value))
|
||||||
if (options.Get(switches::kZoomFactor, &d))
|
web_preferences.Set(switches::kZoomFactor, value);
|
||||||
web_preferences.Set(switches::kZoomFactor, d);
|
|
||||||
|
|
||||||
// Creates the WebContents used by BrowserWindow.
|
// Creates the WebContents used by BrowserWindow.
|
||||||
auto web_contents = WebContents::Create(isolate, web_preferences);
|
auto web_contents = WebContents::Create(isolate, web_preferences);
|
||||||
|
|
|
@ -36,11 +36,20 @@ describe 'chromium feature', ->
|
||||||
|
|
||||||
describe 'window.open', ->
|
describe 'window.open', ->
|
||||||
it 'returns a BrowserWindowProxy object', ->
|
it 'returns a BrowserWindowProxy object', ->
|
||||||
b = window.open 'about:blank', 'test', 'show=no'
|
b = window.open 'about:blank', '', 'show=no'
|
||||||
assert.equal b.closed, false
|
assert.equal b.closed, false
|
||||||
assert.equal b.constructor.name, 'BrowserWindowProxy'
|
assert.equal b.constructor.name, 'BrowserWindowProxy'
|
||||||
b.close()
|
b.close()
|
||||||
|
|
||||||
|
it 'accepts "node-integration" as feature', (done) ->
|
||||||
|
listener = (event) ->
|
||||||
|
window.removeEventListener 'message', listener
|
||||||
|
b.close()
|
||||||
|
assert.equal event.data, 'undefined'
|
||||||
|
done()
|
||||||
|
window.addEventListener 'message', listener
|
||||||
|
b = window.open "file://#{fixtures}/pages/window-opener-node.html", '', 'node-integration=no,show=no'
|
||||||
|
|
||||||
describe 'window.opener', ->
|
describe 'window.opener', ->
|
||||||
ipc = remote.require 'ipc'
|
ipc = remote.require 'ipc'
|
||||||
url = "file://#{fixtures}/pages/window-opener.html"
|
url = "file://#{fixtures}/pages/window-opener.html"
|
||||||
|
@ -58,19 +67,21 @@ describe 'chromium feature', ->
|
||||||
w.loadUrl url
|
w.loadUrl url
|
||||||
|
|
||||||
it 'is not null for window opened by window.open', (done) ->
|
it 'is not null for window opened by window.open', (done) ->
|
||||||
b = window.open url, 'test2', 'show=no'
|
b = window.open url, '', 'show=no'
|
||||||
ipc.on 'opener', (event, opener) ->
|
ipc.on 'opener', (event, opener) ->
|
||||||
b.close()
|
b.close()
|
||||||
done(if opener isnt null then undefined else opener)
|
done(if opener isnt null then undefined else opener)
|
||||||
|
|
||||||
describe 'window.opener.postMessage', ->
|
describe 'window.opener.postMessage', ->
|
||||||
it 'sets source and origin correctly', (done) ->
|
it 'sets source and origin correctly', (done) ->
|
||||||
b = window.open "file://#{fixtures}/pages/window-opener-postMessage.html", 'test', 'show=no'
|
listener = (event) ->
|
||||||
window.addEventListener 'message', (event) ->
|
window.removeEventListener 'message', listener
|
||||||
b.close()
|
b.close()
|
||||||
assert.equal event.source.guestId, b.guestId
|
assert.equal event.source.guestId, b.guestId
|
||||||
assert.equal event.origin, 'file://'
|
assert.equal event.origin, 'file://'
|
||||||
done()
|
done()
|
||||||
|
window.addEventListener 'message', listener
|
||||||
|
b = window.open "file://#{fixtures}/pages/window-opener-postMessage.html", '', 'show=no'
|
||||||
|
|
||||||
describe 'creating a Uint8Array under browser side', ->
|
describe 'creating a Uint8Array under browser side', ->
|
||||||
it 'does not crash', ->
|
it 'does not crash', ->
|
||||||
|
|
7
spec/fixtures/pages/window-opener-node.html
vendored
Normal file
7
spec/fixtures/pages/window-opener-node.html
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
window.opener.postMessage(typeof process, '*')
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue