mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 17:14:42 +00:00
Add Promise.prototype.finally polyfill and restore failing tests
Change-Id: Ia6cdb85d33d2b3e0e2e868838defaa39ae60572a
This commit is contained in:
parent
e4724b3f26
commit
c895c60907
|
@ -1019,6 +1019,8 @@ class VisualEditorHooks {
|
|||
'lib/ve/lib/jsdifflib/diffview.css',
|
||||
],
|
||||
'scripts' => [
|
||||
// Promise.finally polyfill. Can be removed when CI uses Chrome >= 64
|
||||
'lib/proposal-promise-finally/polyfill.js',
|
||||
// MW config preload
|
||||
'modules/ve-mw/tests/mw-preload.js',
|
||||
// jsdifflib
|
||||
|
@ -1091,14 +1093,13 @@ class VisualEditorHooks {
|
|||
'lib/ve/tests/ce/ve.ce.ContentBranchNode.test.js',
|
||||
'modules/ve-mw/tests/ce/ve.ce.ContentBranchNode.test.js',
|
||||
'lib/ve/tests/ce/ve.ce.LeafNode.test.js',
|
||||
// FIXME: These are breaking VE-MW CI tests
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearArrowKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearDeleteKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearEnterKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearEscapeKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.TableArrowKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.TableDeleteKeyDownHandler.test.js',
|
||||
// 'lib/ve/tests/ce/keydownhandlers/ve.ce.TableEnterKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearArrowKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearDeleteKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearEnterKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.LinearEscapeKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.TableArrowKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.TableDeleteKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/keydownhandlers/ve.ce.TableEnterKeyDownHandler.test.js',
|
||||
'lib/ve/tests/ce/nodes/ve.ce.TextNode.test.js',
|
||||
'lib/ve/tests/ce/nodes/ve.ce.TableNode.test.js',
|
||||
// VisualEditor UI Tests
|
||||
|
|
21
lib/proposal-promise-finally/LICENSE
Normal file
21
lib/proposal-promise-finally/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Jordan Harband
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
45
lib/proposal-promise-finally/polyfill.js
Normal file
45
lib/proposal-promise-finally/polyfill.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
if (typeof Promise !== 'function') {
|
||||
throw new TypeError('A global Promise is required');
|
||||
}
|
||||
|
||||
if (typeof Promise.prototype.finally !== 'function') {
|
||||
var speciesConstructor = function (O, defaultConstructor) {
|
||||
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
||||
throw new TypeError('Assertion failed: Type(O) is not Object');
|
||||
}
|
||||
var C = O.constructor;
|
||||
if (typeof C === 'undefined') {
|
||||
return defaultConstructor;
|
||||
}
|
||||
if (!C || (typeof C !== 'object' && typeof C !== 'function')) {
|
||||
throw new TypeError('O.constructor is not an Object');
|
||||
}
|
||||
var S = typeof Symbol === 'function' && typeof Symbol.species === 'symbol' ? C[Symbol.species] : undefined;
|
||||
if (S == null) {
|
||||
return defaultConstructor;
|
||||
}
|
||||
if (typeof S === 'function' && S.prototype) {
|
||||
return S;
|
||||
}
|
||||
throw new TypeError('no constructor found');
|
||||
};
|
||||
|
||||
var shim = {
|
||||
finally(onFinally) {
|
||||
var promise = this;
|
||||
if (typeof promise !== 'object' || promise === null) {
|
||||
throw new TypeError('"this" value is not an Object');
|
||||
}
|
||||
var C = speciesConstructor(promise, Promise); // throws if SpeciesConstructor throws
|
||||
if (typeof onFinally !== 'function') {
|
||||
return Promise.prototype.then.call(promise, onFinally, onFinally);
|
||||
}
|
||||
return Promise.prototype.then.call(
|
||||
promise,
|
||||
x => new C(resolve => resolve(onFinally())).then(() => x),
|
||||
e => new C(resolve => resolve(onFinally())).then(() => { throw e; })
|
||||
);
|
||||
}
|
||||
};
|
||||
Object.defineProperty(Promise.prototype, 'finally', { configurable: true, writable: true, value: shim.finally });
|
||||
}
|
|
@ -60,8 +60,7 @@ QUnit.test( 'handleLinearDelete', function ( assert ) {
|
|||
} );
|
||||
} );
|
||||
|
||||
// VE-MW CI doesn't support finally yet
|
||||
promise.then( function () { done(); }, function () { done(); } );
|
||||
promise.finally( function () { done(); } );
|
||||
} );
|
||||
|
||||
QUnit.test( 'beforePaste/afterPaste', function ( assert ) {
|
||||
|
|
Loading…
Reference in a new issue