Skip to content

Commit 3d63dd6

Browse files
committed
Merge branch 'nw49' into nw50
2 parents 92223d9 + 6c427bb commit 3d63dd6

File tree

12 files changed

+97
-4
lines changed

12 files changed

+97
-4
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
0.49.2 / 11-01-2020
2+
===================
3+
- Update Node.js to [v15.0.1](https://nodejs.org/en/blog/release/v15.0.1/)
4+
- Add mixed_context window option for new_instance window [(#7609)](https://github.com/nwjs/nw.js/issues/7609)
5+
- [docs] mixed_context option in Window.open()
6+
7+
0.49.1 / 10-23-2020
8+
===================
9+
- Update Chromium to [86.0.4240.111](https://chromereleases.googleblog.com/2020/10/stable-channel-update-for-desktop_20.html)
10+
- Update Node.js to [v14.13.1](https://nodejs.org/en/blog/release/v14.13.1/)
11+
- Fix: Linux - Race condition and lags in renderer event loop [(#7497)](https://github.com/nwjs/nw.js/issues/7497)
12+
- Fix: NewWindow.attach in webview [(#7578)](https://github.com/nwjs/nw.js/issues/7578)
13+
- Fix: nw2 Window.capturePage captures wrong window [(#7592)](https://github.com/nwjs/nw.js/issues/7592)
14+
- Fix: nw2 Window not removing listeners on 'loaded' event [(#7593)](https://github.com/nwjs/nw.js/issues/7593)
15+
116
0.49.0 / 10-07-2020
217
===================
318
- Update Chromium to [86.0.4240.75](https://developers.google.com/web/updates/2020/10/nic86)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ It was created in the Intel Open Source Technology Center.
2525
* Available on Linux, Mac OS X and Windows.
2626

2727
## Downloads
28-
* **v0.49.0:** (Oct 7, 2020, based off of Node.js v14.12.0, Chromium 86.0.4240.75) : [release notes](https://nwjs.io/blog/v0.49.0/)
28+
* **v0.49.2:** (Nov 1, 2020, based off of Node.js v15.0.1, Chromium 86.0.4240.111) : [release notes](https://nwjs.io/blog/v0.49.2/)
2929
**NOTE** You might want the **SDK build**. Please read the release notes.
30-
* Linux: [32bit](https://dl.nwjs.io/v0.49.0/nwjs-v0.49.0-linux-ia32.tar.gz) / [64bit](https://dl.nwjs.io/v0.49.0/nwjs-v0.49.0-linux-x64.tar.gz)
31-
* Windows: [32bit](https://dl.nwjs.io/v0.49.0/nwjs-v0.49.0-win-ia32.zip) / [64bit](https://dl.nwjs.io/v0.49.0/nwjs-v0.49.0-win-x64.zip)
32-
* Mac 10.10+: [64bit](https://dl.nwjs.io/v0.49.0/nwjs-v0.49.0-osx-x64.zip)
30+
* Linux: [32bit](https://dl.nwjs.io/v0.49.2/nwjs-v0.49.2-linux-ia32.tar.gz) / [64bit](https://dl.nwjs.io/v0.49.2/nwjs-v0.49.2-linux-x64.tar.gz)
31+
* Windows: [32bit](https://dl.nwjs.io/v0.49.2/nwjs-v0.49.2-win-ia32.zip) / [64bit](https://dl.nwjs.io/v0.49.2/nwjs-v0.49.2-win-x64.zip)
32+
* Mac 10.10+: [64bit](https://dl.nwjs.io/v0.49.2/nwjs-v0.49.2-osx-x64.zip)
3333
* Use [Legacy build](http://nwjs.io/downloads/) for Win XP and early OSX.
3434

3535
* **latest nightly build from git tip**: https://dl.nwjs.io/live-build/

docs/References/Window.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Get all windows with a callback function whose parameter is an array of nw.Windo
7474
* `url` `{String}` URL to be loaded in the opened window
7575
* `options` `{Object}` _Optional_ see [Window subfields](Manifest Format.md#window-subfields) in manifest format. And following extra fields can also be used in options.
7676
- `new_instance` `{Boolean}` _Optional_ whether to open a new window in a separate render process.
77+
- `mixed_context` `{Boolean}` _Optional_ If true, the Node context and DOM context are merged in the new window's process. Use only when `new_instance` is true.
7778
- `inject_js_start` `{String}` _Optional_ the script to be injected before any DOM is constructed and any script is run. See [Manifest format](Manifest Format.md#inject_js_start)
7879
- `inject_js_end` `{String}` _Optional_ the script to be injected after the document object is loaded, before onload event is fired. See [Manifest format](Manifest Format.md#inject_js_end)
7980
- `id` `{String}` _Optional_ the `id` used to identify the window. This will be used to remember the size and position of the window and restore that geometry when a window with the same id is later opened. [See also the Chrome App documentation](https://developer.chrome.com/apps/app_window#type-CreateWindowOptions)

src/api/nw_window.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace nw.Window {
3535
[nodoc] boolean? kiosk;
3636
[nodoc] boolean? focus;
3737
[nodoc] boolean? new_instance;
38+
[nodoc] boolean? mixed_context;
3839
[nodoc] boolean? show_in_taskbar;
3940
[nodoc] DOMString? title;
4041
[nodoc] DOMString? position;

src/browser/nw_content_browser_hooks.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace nw {
5353
namespace {
5454

5555
bool g_pinning_renderer = true;
56+
bool g_mixed_context = false;
5657
bool g_in_webview_apply_attr = false;
5758
bool g_in_webview_apply_attr_allow_nw = false;
5859
} //namespace
@@ -191,6 +192,14 @@ void SetPinningRenderer(bool pin) {
191192
g_pinning_renderer = pin;
192193
}
193194

195+
bool MixedContext() {
196+
return g_mixed_context;
197+
}
198+
199+
void SetMixedContext(bool mixed) {
200+
g_mixed_context = mixed;
201+
}
202+
194203
void SetInWebViewApplyAttr(bool flag, bool allow_nw) {
195204
g_in_webview_apply_attr = flag;
196205
g_in_webview_apply_attr_allow_nw = allow_nw;

src/browser/nw_content_browser_hooks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CONTENT_EXPORT void OverrideWebkitPrefsHook(content::RenderViewHost* rvh, blink:
4949
// content/browser/renderer_host/render_process_host_impl.cc
5050
// content/browser/site_instance_impl.cc
5151
CONTENT_EXPORT bool PinningRenderer();
52+
CONTENT_EXPORT bool MixedContext();
5253

5354
#if defined(OS_MAC)
5455
// ref in chrome/browser/app_controller_mac.mm
@@ -63,6 +64,7 @@ CONTENT_EXPORT bool GetPackageImage(nw::Package* package,
6364
gfx::Image* image);
6465
// ref in extensions/browser/api/app_window/app_window_api.cc
6566
CONTENT_EXPORT void SetPinningRenderer(bool pin);
67+
CONTENT_EXPORT void SetMixedContext(bool);
6668

6769
// browser
6870
// ref in content/nw/src/api/tray/tray_aura.cc

src/renderer/nw_extensions_renderer_hooks.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ void ContextCreationHook(blink::WebLocalFrame* frame, ScriptContext* context) {
219219

220220
if (extension)
221221
extension->manifest()->GetBoolean(manifest_keys::kNWJSMixedContext, &mixed_context);
222+
if (!mixed_context) {
223+
mixed_context = command_line.HasSwitch("mixed-context");
224+
}
222225
// handle navigation in webview #5622
223226
if (nwjs_guest_nw)
224227
mixed_context = true;

src/resources/api_nw_newwin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,12 @@ apiBridge.registerCustomHook(function(bindingsAPI) {
809809
options.new_instance = true;
810810
options.setSelfAsOpener = false;
811811
}
812+
if (params.mixed_context === true) {
813+
if (params.new_instance !== true) {
814+
throw new Error('mixed_context should be set with new_instance in nw.Window.open');
815+
}
816+
options.mixed_context = true;
817+
}
812818
if (params.position)
813819
options.position = params.position;
814820
if (params.title)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>child.html</title>
7+
</head>
8+
<body>
9+
<script>document.write('<h1 id="result">typeof module = ' + typeof module + '</h1>')</script>
10+
</body>
11+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>issue5163</title>
7+
</head>
8+
<body>
9+
<button id="spawnRender" type="button" onclick="spawnRender()">Create New Instance Window</button>
10+
<script>
11+
function spawnRender() {
12+
nw.Window.open('child.html', {new_instance: true, mixed_context: true});
13+
}
14+
</script>
15+
</body>
16+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "issue5163-new-instance",
3+
"main": "index.html"
4+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import time
2+
import os
3+
import sys
4+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
5+
from nw_util import *
6+
7+
from selenium import webdriver
8+
from selenium.webdriver.chrome.options import Options
9+
chrome_options = Options()
10+
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
11+
12+
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options)
13+
try:
14+
print driver.current_url
15+
driver.find_element_by_id('spawnRender').click()
16+
print 'wait for window open'
17+
wait_window_handles(driver, 2)
18+
print driver.window_handles
19+
print 'switch to 1st window'
20+
driver.switch_to_window(driver.window_handles[-1])
21+
result1 = driver.find_element_by_id('result').get_attribute('innerHTML')
22+
print result1
23+
assert('object' in result1)
24+
finally:
25+
driver.quit()

0 commit comments

Comments
 (0)