Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: polyfill.js

Issue 30024555: Issue 7334 - Remove support for callbacks in API wrappers (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Rebase Created April 24, 2019, 2:37 p.m.
Right Patch Set: Remove checks Created April 25, 2019, 9:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 let {object, name, func} = wrappables; 105 let {object, name, func} = wrappables;
106 106
107 // If the property is not writable assigning it will fail, so we use 107 // If the property is not writable assigning it will fail, so we use
108 // Object.defineProperty here instead. Assuming the property isn't 108 // Object.defineProperty here instead. Assuming the property isn't
109 // inherited its other attributes (e.g. enumerable) are preserved, 109 // inherited its other attributes (e.g. enumerable) are preserved,
110 // except for accessor attributes (e.g. get and set) which are discarded 110 // except for accessor attributes (e.g. get and set) which are discarded
111 // since we're specifying a value. 111 // since we're specifying a value.
112 Object.defineProperty(object, name, { 112 Object.defineProperty(object, name, {
113 value(...args) 113 value(...args)
114 { 114 {
115 let lastArgumentType = typeof args[args.length - 1];
116
117 // If the last argument is undefined, we assume it stands for the
118 // optional callback.
119 if (lastArgumentType == "function" || lastArgumentType == "undefined")
120 throw new Error("Callbacks are no longer supported.");
121
122 let resolvePromise = null; 115 let resolvePromise = null;
123 let rejectPromise = null; 116 let rejectPromise = null;
124 117
125 func.call(object, ...args, result => 118 func.call(object, ...args, result =>
126 { 119 {
127 let error = browser.runtime.lastError; 120 let error = browser.runtime.lastError;
128 if (error && !portClosedBeforeResponseError.test(error.message)) 121 if (error && !portClosedBeforeResponseError.test(error.message))
129 { 122 {
130 // runtime.lastError is already an Error instance on Edge, while on 123 // runtime.lastError is already an Error instance on Edge, while on
131 // Chrome it is a plain object with only a message property. 124 // Chrome it is a plain object with only a message property.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (typeof OffscreenCanvas == "undefined") 349 if (typeof OffscreenCanvas == "undefined")
357 { 350 {
358 self.OffscreenCanvas = function(width, height) 351 self.OffscreenCanvas = function(width, height)
359 { 352 {
360 let canvas = document.createElement("canvas"); 353 let canvas = document.createElement("canvas");
361 canvas.width = width; 354 canvas.width = width;
362 canvas.height = height; 355 canvas.height = height;
363 return canvas; 356 return canvas;
364 }; 357 };
365 } 358 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld