Skip to content
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
872cb22
Prevent crash on `nw.showDevTools` on non-sdk build
ayushmanchhabra Mar 3, 2023
e760ba4
build: fix python not found error
ayushmanchhabra Mar 6, 2023
bc4e111
build(node): `copy_node` should not refer to Debug on Release
ayushmanchhabra Mar 7, 2023
71fa5de
test: start test case
ayushmanchhabra Mar 7, 2023
ea9db44
test: remove tmp file
ayushmanchhabra Mar 7, 2023
d76cdc9
test: only run test if flavor is not sdk
ayushmanchhabra Mar 7, 2023
a97c0be
EoL
TheJaredWilcurt Mar 8, 2023
4cfc2dc
Add doctype
TheJaredWilcurt Mar 8, 2023
df4d9a3
test: move test from sanity to manual
ayushmanchhabra Mar 8, 2023
5eb3e40
test: resolve merge conflicts
ayushmanchhabra Mar 8, 2023
e800cf0
build: run using Python3
ayushmanchhabra Mar 8, 2023
3038d82
test: uncomment manual test code
ayushmanchhabra Mar 10, 2023
7185cdb
Merge branch 'nw74' of github.com:tharatau/nw-core into nw74
ayushmanchhabra Mar 10, 2023
f099d8d
build: revert incorrect config change
ayushmanchhabra Mar 15, 2023
adcac6d
build: revert unnecessary change
ayushmanchhabra Mar 15, 2023
176206e
fix(test): prevent crash
ayushmanchhabra Mar 15, 2023
065413e
Merge branch 'nwjs:nw74' into dev-8012
ayushmanchhabra Mar 28, 2023
344b401
chore: revert git ignore log file
ayushmanchhabra Apr 4, 2023
8d75ac4
chore: revert icu patch
ayushmanchhabra Apr 4, 2023
2d62074
[Resources/Window] Throw error if build flavor not `sdk`
ayushmanchhabra Apr 18, 2023
cd89214
[Resources/Window] Throw error if build flavor not `sdk`
ayushmanchhabra Apr 18, 2023
51c9a63
test: catch error to prevent crash
ayushmanchhabra Apr 20, 2023
079d890
Merge branch 'nwjs:nw75' into dev-8012
ayushmanchhabra Apr 20, 2023
f46075c
docs: change of behaviour note in docs
ayushmanchhabra Apr 20, 2023
c908e4f
Update docs/References/Window.md
ayushmanchhabra Apr 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/References/Window.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ Turn the window's native shadow on/off. Useful for frameless, transparent window
!!! warning "Behavior Changed"
The behavior of the function is changed since 0.13.0. Please see [Migration Notes from 0.12 to 0.13](../For Users/Migration/From 0.12 to 0.13.md).

!!! note
Since 0.75, the function throws an error if the build flavor is not SDK. This error can be caught in a try catch block which prevents the application from crashing.
Comment thread
ayushmanchhabra marked this conversation as resolved.
Outdated

* `iframe` `{String} or {HTMLIFrameElement}` _Optional_ the id or the element of the `<iframe>` to be jailed on. By default, the DevTools is shown for entire window.
* `callback(dev_win)` `{Function}` callback with the native window of the DevTools window.

Expand Down
20 changes: 14 additions & 6 deletions src/resources/api_nw_newwin.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,23 @@ NWWindow.prototype.toggleKioskMode = function() {
currentNWWindowInternal.toggleKioskModeInternal(this.cWindow.id);
};

NWWindow.prototype.showDevTools = function(frm, callback) {
var id = '';
if (typeof frm === 'string')
id = frm;
var f = null;
/**
* Open the devtools to inspect the new window.
*
* @param {string | HTMLIFrameElement} iframe
* @param {Function} callback
Comment thread
ayushmanchhabra marked this conversation as resolved.
*/
NWWindow.prototype.showDevTools = function(iframe, callback) {
if (process.versions['nw-flavor'] !== 'sdk')
throw new Error('showDevTools does not exist on normal build flavor.');
Comment thread
TheJaredWilcurt marked this conversation as resolved.
let id = '';
if (typeof iframe === 'string')
id = iframe;
let f = null;
if (id)
f = this.window.getElementById(id);
else
f = frm || null;
f = iframe || null;
nwNatives.setDevToolsJail(f);
currentNWWindowInternal.showDevTools2Internal(this.cWindow.id, callback);
};
Expand Down
20 changes: 14 additions & 6 deletions src/resources/api_nw_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,23 @@ apiBridge.registerCustomHook(function(bindingsAPI) {
currentNWWindowInternal.toggleKioskModeInternal();
};

NWWindow.prototype.showDevTools = function(frm, callback) {
var id = '';
if (typeof frm === 'string')
id = frm;
var f = null;
/**
* Open the devtools to inspect the current window.
*
* @param {string | HTMLIFrameElement} iframe
* @param {Function} callback
*/
NWWindow.prototype.showDevTools = function(iframe, callback) {
if (process.versions['nw-flavor'] !== 'sdk')
throw new Error('showDevTools does not exist on normal build flavor.');
Comment thread
TheJaredWilcurt marked this conversation as resolved.
let id = '';
if (typeof iframe === 'string')
id = iframe;
let f = null;
if (id)
f = this.appWindow.contentWindow.getElementById(id);
else
f = frm || null;
f = iframe || null;
nwNatives.setDevToolsJail(f);
currentNWWindowInternal.showDevToolsInternal(callback);
};
Expand Down
27 changes: 27 additions & 0 deletions test/manual/window-showdevtools/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>

<head>
<script>
document.addEventListener("DOMContentLoaded", () => {
const process = require("process");
const w = nw.Window.get();
document.getElementById("flavor").innerText = "Flavor: " + process.versions["nw-flavor"];
try {
w.showDevTools();
} catch (error) {
document.getElementById("result").innerText = error;
}

});
</script>
</head>

<body>
<span>The showDevTools function is executted on DOMContentLoaded. If flavor is normal and nw does not crash (assuming error is caught in a try/catch block), test is succesful.</span>
<br>
<span id="flavor"></span>
<br>
<span id="result"></span>
</body>

</html>
4 changes: 4 additions & 0 deletions test/manual/window-showdevtools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "window-showdevtools",
"main": "index.html"
}