jenkins-bot has submitted this change and it was merged.
Change subject: Remove CSS readiness workaround
......................................................................
Remove CSS readiness workaround
RL's support for this should be bug-free now
Bug: T63852
Change-Id: Iaa6355648dcc1eb1780a7b1ee7e461d4213e3017
---
M MultimediaViewer.php
M resources/mmv/mmv.bootstrap.js
D resources/mmv/mmv.loaded.css
M tests/qunit/mmv/mmv.bootstrap.test.js
4 files changed, 14 insertions(+), 72 deletions(-)
Approvals:
Krinkle: Looks good to me, but someone else must approve
Gergő Tisza: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MultimediaViewer.php b/MultimediaViewer.php
index 7ada8a1..85c55a9 100644
--- a/MultimediaViewer.php
+++ b/MultimediaViewer.php
@@ -201,8 +201,6 @@
'mmv/ui/mmv.ui.metadataPanel.less',
'mmv/ui/mmv.ui.metadataPanelScroller.less',
'mmv/mmv.lightboxinterface.less',
- // Always make this one the last of the list (Bug 61852)
- 'mmv/mmv.loaded.css',
),
'dependencies' => array(
diff --git a/resources/mmv/mmv.bootstrap.js b/resources/mmv/mmv.bootstrap.js
index e7c6790..2a2ef4d 100644
--- a/resources/mmv/mmv.bootstrap.js
+++ b/resources/mmv/mmv.bootstrap.js
@@ -41,8 +41,6 @@
};
// Exposed for tests
- this.readinessCSSClass = 'mw-mmv-has-been-loaded';
- this.readinessWaitDuration = 100;
this.hoverWaitDuration = 200;
// TODO lazy-load config and htmlUtils
@@ -85,7 +83,9 @@
*/
MMVB.loadViewer = function () {
var deferred = $.Deferred(),
- bs = this;
+ bs = this,
+ viewer,
+ message;
// Don't load if someone has specifically stopped us from doing
so
if ( mw.config.get( 'wgMediaViewer' ) !== true ) {
@@ -95,7 +95,17 @@
bs.setupOverlay();
mw.loader.using( 'mmv', function () {
- bs.isCSSReady( deferred );
+ try {
+ viewer = bs.getViewer();
+ } catch ( e ) {
+ message = e.message;
+ if ( e.stack ) {
+ message += '\n' + e.stack;
+ }
+ deferred.reject( message );
+ return;
+ }
+ deferred.resolve( viewer );
}, function ( error ) {
deferred.reject( error.message );
} );
@@ -114,38 +124,6 @@
bs.viewerIsBroken = true;
mw.notify( 'Error loading MediaViewer: ' + message );
} );
- };
-
- /**
- * Checks if the mmv CSS has been correctly added to the page
- * This is a workaround for core bug 61852
- * @param {jQuery.Promise.<mw.mmv.MultimediaViewer>} deferred
- */
- MMVB.isCSSReady = function ( deferred ) {
- var $dummy = $( '<div class="' + this.readinessCSSClass + '">' )
- .appendTo( $( document.body ) ),
- bs = this,
- viewer,
- message;
-
- if ( $dummy.css( 'display' ) === 'inline' ) {
- // Let's be clean and remove the test item before
resolving the deferred
- $dummy.remove();
- try {
- viewer = bs.getViewer();
- } catch ( e ) {
- message = e.message;
- if ( e.stack ) {
- message += '\n' + e.stack;
- }
- deferred.reject( message );
- return;
- }
- deferred.resolve( viewer );
- } else {
- $dummy.remove();
- setTimeout( function () { bs.isCSSReady( deferred ); },
this.readinessWaitDuration );
- }
};
/**
diff --git a/resources/mmv/mmv.loaded.css b/resources/mmv/mmv.loaded.css
deleted file mode 100644
index c9c41ac..0000000
--- a/resources/mmv/mmv.loaded.css
+++ /dev/null
@@ -1,8 +0,0 @@
-.mw-mmv-has-been-loaded {
- display: inline;
-}
-/* Makes sure this has more specificity than the display: none in
mmv.bootstrap.less; keep separate from previous
- block for maximum browser compatibility */
-body.mw-mmv-lightbox-open > .mw-mmv-has-been-loaded {
- display: inline;
-}
diff --git a/tests/qunit/mmv/mmv.bootstrap.test.js
b/tests/qunit/mmv/mmv.bootstrap.test.js
index 9ddd3aa..61a2ccf 100644
--- a/tests/qunit/mmv/mmv.bootstrap.test.js
+++ b/tests/qunit/mmv/mmv.bootstrap.test.js
@@ -408,32 +408,6 @@
window.location.hash = '';
} );
- QUnit.test( 'isCSSReady', 3, function ( assert ) {
- var bootstrap = createBootstrap(),
- deferred = $.Deferred(),
- CSSclass = 'foo-' + $.now(),
- $style = $( '<style type="text/css" />' )
- .text( '.' + CSSclass + ' { display: inline; }'
);
-
- bootstrap.readinessCSSClass = CSSclass;
- bootstrap.isCSSReady( deferred );
-
- assert.strictEqual( deferred.state(), 'pending', 'The style
isn\'t on the page yet' );
-
- QUnit.stop();
-
- deferred.then( function () {
- QUnit.start();
- assert.ok( true, 'The style is on the page' );
- assert.strictEqual( $( '.' + CSSclass ).length, 0,
'There are no leftover test elements' );
- $style.remove();
- } );
-
- $style.appendTo( 'head' );
-
- this.clock.tick( bootstrap.readinessWaitDuration );
- } );
-
QUnit.test( 'Restoring article scroll position', 2, function ( assert )
{
var bootstrap = createBootstrap(),
scrollTop = 50,
--
To view, visit https://gerrit.wikimedia.org/r/235988
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa6355648dcc1eb1780a7b1ee7e461d4213e3017
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits