jenkins-bot has submitted this change and it was merged.
Change subject: mw.Debug.profile: Tweak support check to handle PhantomJS
......................................................................
mw.Debug.profile: Tweak support check to handle PhantomJS
* Latest PhantomJS (1.9.7) supports Array.prototype.map,
Array.prototype.reduce, Array.prototype.filter, and
document.createElementNS, but not Function.prototype.bind
* Check all of these in the init function, and if they're available
continue (unless there's no profiling data) and initialize
this.createSvgElement (previously done inline)
* Accordingly, rename buildRequiresES5 to buildRequiresBrowserFeatures
and tweak message
Change-Id: If464b1093ec445afbb6c6b8c230e0e2669ad8c5c
---
M resources/src/mediawiki/mediawiki.debug.profile.js
1 file changed, 16 insertions(+), 8 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/src/mediawiki/mediawiki.debug.profile.js
b/resources/src/mediawiki/mediawiki.debug.profile.js
index 7bbbbd3..04f7acd 100644
--- a/resources/src/mediawiki/mediawiki.debug.profile.js
+++ b/resources/src/mediawiki/mediawiki.debug.profile.js
@@ -37,11 +37,21 @@
// only drop events if requested
dropThresholdPx = dropThresholdPx || 0;
- if ( !Array.prototype.map || !Array.prototype.reduce ||
!Array.prototype.filter ) {
- profile.container = profile.buildRequiresES5();
+ if (
+ !Array.prototype.map ||
+ !Array.prototype.reduce ||
+ !Array.prototype.filter ||
+ !document.createElementNS ||
+ !document.createElementNS.bind
+ ) {
+ profile.container =
profile.buildRequiresBrowserFeatures();
} else if ( data.length === 0 ) {
profile.container = profile.buildNoData();
} else {
+ // Initialize createSvgElement (now that we
know we have
+ // document.createElementNS and bind)
+ this.createSvgElement =
document.createElementNS.bind( document, 'http://www.w3.org/2000/svg' );
+
// generate a flyout
profile.data = new ProfileData( data,
profile.width, mergeThresholdPx, dropThresholdPx );
// draw it
@@ -52,9 +62,9 @@
return profile.container;
},
- buildRequiresES5: function () {
+ buildRequiresBrowserFeatures: function () {
return $( '<div>' )
- .text( 'An ES5 compatible javascript engine is
required for the profile visualization.' )
+ .text( 'Certain browser features, including
parts of ECMAScript 5 and document.createElementNS, are required for the
profile visualization.' )
.get( 0 );
},
@@ -66,14 +76,12 @@
/**
* Creates DOM nodes appropriately namespaced for SVG.
+ * Initialized in init after checking support
*
* @param string tag to create
* @return DOMElement
*/
- createSvgElement: ( document.createElementNS &&
Function.prototype.bind )
- ? document.createElementNS.bind( document,
'http://www.w3.org/2000/svg' )
- // throw a error for browsers which does not support
document.createElementNS (IE<8)
- : function () { throw new Error( 'An ES5 compatible
javascript engine is required for the profile visualization.' ); },
+ createSvgElement: null,
/**
* @param DOMElement|undefined
--
To view, visit https://gerrit.wikimedia.org/r/144601
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If464b1093ec445afbb6c6b8c230e0e2669ad8c5c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits