|
| 1 | +<html> |
| 2 | +<head> |
| 3 | +<style> |
| 4 | + button { |
| 5 | + -webkit-app-region: no-drag; |
| 6 | + } |
| 7 | +</style> |
| 8 | +</head> |
| 9 | +<body style="-webkit-user-select: none; -webkit-app-region: drag"> |
| 10 | +<script> |
| 11 | + var gui = nw; |
| 12 | + var win; |
| 13 | + gui.Window.open('newpop.html', { |
| 14 | + x: 100, y: 100, width: 200, height: 300 |
| 15 | + }, function(w) { win = w; |
| 16 | + |
| 17 | + win.on('closed', function() { |
| 18 | + console.log('popup window is closed.'); |
| 19 | + win = null; |
| 20 | + }); |
| 21 | + |
| 22 | + win.on('loading', function() { |
| 23 | + console.log('start to load new window.'); |
| 24 | + }); |
| 25 | + |
| 26 | + win.on('loaded', function() { |
| 27 | + console.log('new window loaded.'); |
| 28 | + }); |
| 29 | + }); |
| 30 | + |
| 31 | + function takeSnapshot() { |
| 32 | + gui.Window.get().capturePage(function(img) { |
| 33 | + var image = win.window.document.getElementById('image'); |
| 34 | + image.src = img; |
| 35 | + |
| 36 | + }, 'png'); |
| 37 | + } |
| 38 | + |
| 39 | + gui.Window.get().on('close', function() { |
| 40 | + if (win != null) |
| 41 | + win.close(true); |
| 42 | + this.close(true); |
| 43 | + }); |
| 44 | + |
| 45 | + gui.Window.get().show(); |
| 46 | +</script> |
| 47 | +<button onclick="win.focus()">Focus</button> |
| 48 | +<br/> |
| 49 | +<button onclick="win.blur()">Blur</button> |
| 50 | +<br/> |
| 51 | +<button onclick="win.show()">Show</button> |
| 52 | +<br/> |
| 53 | +<button onclick="win.hide()">Hide</button> |
| 54 | +<br/> |
| 55 | +<button onclick="win.maximize()">Maximize</button> |
| 56 | +<br/> |
| 57 | +<button onclick="win.unmaximize()">Unmaximize</button> |
| 58 | +<br/> |
| 59 | +<button onclick="win.minimize()">Minimize</button> |
| 60 | +<br/> |
| 61 | +<button onclick="win.restore()">Restore</button> |
| 62 | +<br/> |
| 63 | +<button onclick="win.enterFullscreen()">EnterFullscreen</button> |
| 64 | +<br/> |
| 65 | +<button onclick="win.leaveFullscreen()">LeaveFullscreen</button> |
| 66 | +<br/> |
| 67 | +<button onclick="win.close()">Close</button> |
| 68 | +<br/> |
| 69 | +<button onclick="win.close(true)">Force Close</button> |
| 70 | +<br/> |
| 71 | +<button onclick="win.showDevTools()">Open DevTools</button> |
| 72 | +<br/> |
| 73 | +<button onclick="win.setMinimumSize(100, 200)">setMinimumSize(100, 200)</button> |
| 74 | +<br/> |
| 75 | +<button onclick="win.setMaximumSize(200, 400)">setMaximumSize(200, 400)</button> |
| 76 | +<br/> |
| 77 | +<button onclick="win.moveTo(0, 0)">moveTo(0, 0)</button> |
| 78 | +<br/> |
| 79 | +<button onclick="win.moveBy(10, 20)">moveBy(10, 20)</button> |
| 80 | +<br/> |
| 81 | +<button id='btn_resizeto' onclick="win.resizeTo(180, 180)">resizeTo(180, 180)</button> |
| 82 | +<br/> |
| 83 | +<button onclick="win.resizeBy(10, 20)">resizeBy(10, 20)</button> |
| 84 | +<br/> |
| 85 | +<button onclick="win.setResizable(true)">setResizable(true)</button> |
| 86 | +<button onclick="win.setResizable(false)">(false)</button> |
| 87 | +<br/> |
| 88 | +<p>Focus another application within 2sec, popup window should on top.</p> |
| 89 | +<button onclick="setTimeout(function(){win.setAlwaysOnTop(true);},2000)">setAlwaysOnTop(true)</button> |
| 90 | +<button onclick="win.setAlwaysOnTop(false)">(false)</button> |
| 91 | +<br/> |
| 92 | +<button onclick="win.zoomLevel = 2">set zoomLevel to 2</button> |
| 93 | +<br/> |
| 94 | +<button onclick="win.zoomLevel = 0">set zoomLevel to 0</button> |
| 95 | +<br/> |
| 96 | +<button onclick="takeSnapshot()">takeSnapshot</button> |
| 97 | +<br/> |
| 98 | +Reload the window and do all tests again. |
| 99 | +<button onclick="win.reload()">Reload</button> |
| 100 | +</body> |
| 101 | +</html> |
0 commit comments