Skip to content

Commit 80d4209

Browse files
committed
Update web-contents module
1 parent 2bd3c04 commit 80d4209

File tree

2 files changed

+492
-6
lines changed

2 files changed

+492
-6
lines changed

github-electron/github-electron-main-tests.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ app.on('ready', () => {
6969
mainWindow.webContents.addWorkSpace('/path/to/workspace');
7070
mainWindow.webContents.removeWorkSpace('/path/to/workspace');
7171
var opened: boolean = mainWindow.webContents.isDevToolsOpened()
72-
var focused = mainWindow.webContents.isDevToolsFocused();
72+
var focused = mainWindow.webContents.isDevToolsFocused();
7373
// Emitted when the window is closed.
7474
mainWindow.on('closed', () => {
7575
// Dereference the window object, usually you would store windows
@@ -83,11 +83,6 @@ app.on('ready', () => {
8383
mainWindow.print();
8484
mainWindow.webContents.print();
8585

86-
mainWindow.print({silent: true, printBackground: false});
87-
mainWindow.webContents.print({silent: true, printBackground: false});
88-
mainWindow.print();
89-
mainWindow.webContents.print();
90-
9186
mainWindow.printToPDF({
9287
marginsType: 1,
9388
pageSize: 'A3',
@@ -119,6 +114,35 @@ app.on('ready', () => {
119114
mainWindow.webContents.stopFindInPage('clearSelection');
120115
mainWindow.webContents.stopFindInPage('keepSelection');
121116
mainWindow.webContents.stopFindInPage('activateSelection');
117+
118+
mainWindow.loadURL('https://github.com');
119+
120+
mainWindow.webContents.on('did-finish-load', function() {
121+
mainWindow.webContents.savePage('/tmp/test.html', 'HTMLComplete', function(error) {
122+
if (!error)
123+
console.log("Save page successfully");
124+
});
125+
});
126+
127+
try {
128+
mainWindow.webContents.debugger.attach("1.1");
129+
} catch(err) {
130+
console.log("Debugger attach failed : ", err);
131+
};
132+
133+
mainWindow.webContents.debugger.on('detach', function(event, reason) {
134+
console.log("Debugger detached due to : ", reason);
135+
});
136+
137+
mainWindow.webContents.debugger.on('message', function(event, method, params) {
138+
if (method == "Network.requestWillBeSent") {
139+
if (params.request.url == "https://www.github.com") {
140+
win.webContents.debugger.detach();
141+
}
142+
}
143+
});
144+
145+
mainWindow.webContents.debugger.sendCommand("Network.enable");
122146
});
123147

124148
// Locale

0 commit comments

Comments
 (0)