Browse Source

Assert document visibility in main context

Kevin Sawicki 8 years ago
parent
commit
1d824d4645
3 changed files with 13 additions and 4 deletions
  1. 3 1
      spec/api-browser-window-spec.js
  2. 3 1
      spec/fixtures/api/isolated.html
  3. 7 2
      spec/webview-spec.js

+ 3 - 1
spec/api-browser-window-spec.js

@@ -1853,7 +1853,9 @@ describe('BrowserWindow module', function () {
         typeofArrayPush: 'number',
         typeofFunctionApply: 'boolean',
         typeofPreloadExecuteJavaScriptProperty: 'number',
-        typeofOpenedWindow: 'object'
+        typeofOpenedWindow: 'object',
+        documentHidden: true,
+        documentVisibilityState: 'hidden'
       }
     }
 

+ 3 - 1
spec/fixtures/api/isolated.html

@@ -19,7 +19,9 @@
         typeofArrayPush: typeof Array.prototype.push,
         typeofFunctionApply: typeof Function.prototype.apply,
         typeofPreloadExecuteJavaScriptProperty: typeof window.preloadExecuteJavaScriptProperty,
-        typeofOpenedWindow: typeof opened
+        typeofOpenedWindow: typeof opened,
+        documentHidden: document.hidden,
+        documentVisibilityState: document.visibilityState
       }, '*')
     </script>
   </head>

+ 7 - 2
spec/webview-spec.js

@@ -2,9 +2,12 @@ const assert = require('assert')
 const path = require('path')
 const http = require('http')
 const url = require('url')
-const {app, session, getGuestWebContents, ipcMain, BrowserWindow, webContents} = require('electron').remote
+const {remote} = require('electron')
+const {app, session, getGuestWebContents, ipcMain, BrowserWindow, webContents} = remote
 const {closeWindow} = require('./window-helpers')
 
+const isCI = remote.getGlobal('isCi')
+
 describe('<webview> tag', function () {
   this.timeout(3 * 60 * 1000)
 
@@ -449,7 +452,9 @@ describe('<webview> tag', function () {
             typeofArrayPush: 'number',
             typeofFunctionApply: 'boolean',
             typeofPreloadExecuteJavaScriptProperty: 'number',
-            typeofOpenedWindow: 'object'
+            typeofOpenedWindow: 'object',
+            documentHidden: isCI,
+            documentVisibilityState: isCI ? 'hidden' : 'visible'
           }
         })
         done()