Add failing spec for inheriting Javascript web preference
authorKevin Sawicki <kevinsawicki@gmail.com>
Fri, 21 Apr 2017 17:58:47 +0000 (10:58 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 25 Apr 2017 19:57:53 +0000 (12:57 -0700)
spec/chromium-spec.js
spec/fixtures/pages/window-no-javascript.html [new file with mode: 0644]

index 4c5b855..977f25e 100644 (file)
@@ -229,6 +229,31 @@ describe('chromium feature', function () {
       b = window.open(windowUrl, '', 'nodeIntegration=no,show=no')
     })
 
+    it('disables JavaScript when it is disabled on the parent window', function (done) {
+      var b
+      app.once('web-contents-created', (event, contents) => {
+        contents.once('did-finish-load', () => {
+          app.once('browser-window-created', (event, window) => {
+            const preferences = window.webContents.getWebPreferences()
+            assert.equal(preferences.javascript, false)
+            window.destroy()
+            b.close()
+            done()
+          })
+          // Click link on page
+          contents.sendInputEvent({type: 'mouseDown', clickCount: 1, x: 1, y: 1})
+          contents.sendInputEvent({type: 'mouseUp', clickCount: 1, x: 1, y: 1})
+        })
+      })
+
+      var windowUrl = require('url').format({
+        pathname: `${fixtures}/pages/window-no-javascript.html`,
+        protocol: 'file',
+        slashes: true
+      })
+      b = window.open(windowUrl, '', 'javascript=no,show=no')
+    })
+
     it('does not override child options', function (done) {
       var b, size
       size = {
diff --git a/spec/fixtures/pages/window-no-javascript.html b/spec/fixtures/pages/window-no-javascript.html
new file mode 100644 (file)
index 0000000..9c38c9e
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<style>
+  * {
+    padding: 0;
+    margin: 0;
+  }
+</style>
+<body>
+<a href="about:blank>" target="_blank">CLICK</a>
+</body>
+</html>