From 2b52ecbccf5f1eca2c2f26490c1ce599141c7bf2 Mon Sep 17 00:00:00 2001 From: Ha The Dzung Date: Tue, 27 Jun 2017 15:41:18 +0700 Subject: [PATCH 1/2] Add METHODS_LENGTH to IVPAIDAdUnit to avoid error when closure compiler --- js/IVPAIDAdUnit.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/IVPAIDAdUnit.js b/js/IVPAIDAdUnit.js index cb05529..9f84427 100644 --- a/js/IVPAIDAdUnit.js +++ b/js/IVPAIDAdUnit.js @@ -15,6 +15,22 @@ var METHODS = [ 'unsubscribe' ]; +// for avoiding argument leaking +var METHODS_LENGTH = { + 'handshakeVersion': 2, + 'initAd': 7, + 'startAd': 1, + 'stopAd': 1, + 'skipAd': 1, // VPAID 2.0 new method + 'resizeAd': 4, + 'pauseAd': 1, + 'resumeAd': 1, + 'expandAd': 1, + 'collapseAd': 1, + 'subscribe': 3, + 'unsubscribe': 2 +}; + var EVENTS = [ 'AdLoaded', 'AdStarted', @@ -257,6 +273,7 @@ IVPAIDAdUnit.prototype.getAdIcons = function(callback) {}; IVPAIDAdUnit.prototype.setAdVolume = function(volume, callback) {}; addStaticToInterface(IVPAIDAdUnit, 'METHODS', METHODS); +addStaticToInterface(IVPAIDAdUnit, 'METHODS_LENGTH', METHODS_LENGTH); addStaticToInterface(IVPAIDAdUnit, 'GETTERS', GETTERS); addStaticToInterface(IVPAIDAdUnit, 'SETTERS', SETTERS); addStaticToInterface(IVPAIDAdUnit, 'EVENTS', EVENTS); From d857b98d2cb9bc424380c38612b5c0f2454fbee0 Mon Sep 17 00:00:00 2001 From: Ha The Dzung Date: Tue, 27 Jun 2017 15:44:31 +0700 Subject: [PATCH 2/2] Correct getting ariaty of method in VPAIDAdUnit --- js/VPAIDAdUnit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/VPAIDAdUnit.js b/js/VPAIDAdUnit.js index a40fcc2..1339b48 100644 --- a/js/VPAIDAdUnit.js +++ b/js/VPAIDAdUnit.js @@ -62,7 +62,7 @@ IVPAIDAdUnit.METHODS.forEach(function(method) { if (ignores.indexOf(method) !== -1) return; VPAIDAdUnit.prototype[method] = function () { - var ariaty = IVPAIDAdUnit.prototype[method].length; + var ariaty = IVPAIDAdUnit.METHODS_LENGTH[method]; // TODO avoid leaking arguments // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments var args = Array.prototype.slice.call(arguments);