From ee20038dce8b0da068b33e0b26ac769744945f83 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Tue, 26 Feb 2013 21:37:57 -0500 Subject: [PATCH 1/2] Fix #1184: Add missing argument to .apply() The Javascript .apply() method takes two arguments: A context argument and an array of values. In CPWebScriptObject callWebScriptMethod:withArguments, only an array of arguments was passed to the .apply() method. This fix inserts `this` as the first argument, and the array of arguments as the second. This has been converted to a pull request from the original issue (#1184) The original issue also suggested a fix for handling namespaces, which are not incorporated in this patch. --- AppKit/CPWebView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index daacbc3c0..0370e1644 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -962,7 +962,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; { try { - return _window[methodName].apply(args); + return _window[methodName].apply(this, args); } catch (e) { From 02460f0e9dd115f6e4e4d9e1ed712e9f68a48074 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Wed, 27 Feb 2013 09:07:21 -0500 Subject: [PATCH 2/2] Change `this` to `_window` in apply() --- AppKit/CPWebView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index 0370e1644..98cc59caa 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -962,7 +962,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; { try { - return _window[methodName].apply(this, args); + return _window[methodName].apply(_window, args); } catch (e) {