From e83b99b0e1c120ec480c6b0a4410bdf1aa7b89cc Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Thu, 20 Oct 2016 17:44:10 +0200 Subject: [PATCH 1/2] Run javascript on document element This enables `:jseval` for users who disable javascript on webpages. --- qutebrowser/browser/webkit/webkittab.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 507a9ba94..2a7fcc3b4 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -624,7 +624,8 @@ class WebKitTab(browsertab.AbstractTab): def run_js_async(self, code, callback=None, *, world=None): if world is not None and world != usertypes.JsWorld.jseval: log.webview.warning("Ignoring world ID {}".format(world)) - result = self._widget.page().mainFrame().evaluateJavaScript(code) + result = self._widget.page().mainFrame().documentElement() \ + .evaluateJavaScript(code) if callback is not None: callback(result) From c537b901f07bd00ee938a5bc8b355cb95b3dd6e3 Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Fri, 21 Oct 2016 00:31:02 +0200 Subject: [PATCH 2/2] Add test for jseval when javascript is disabled --- tests/end2end/features/javascript.feature | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/end2end/features/javascript.feature b/tests/end2end/features/javascript.feature index a86d88e20..dda097f00 100644 --- a/tests/end2end/features/javascript.feature +++ b/tests/end2end/features/javascript.feature @@ -71,3 +71,8 @@ Feature: Javascript stuff And I run :tab-only And I run :jseval if (window.open('about:blank')) { console.log('window opened'); } else { console.log('error while opening window'); } Then the javascript message "error while opening window" should be logged + + Scenario: Executing jseval when javascript is disabled + When I set content -> allow-javascript to false + And I run :jseval console.log('jseval executed') + Then the javascript message "jseval executed" should be logged