r107946 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107945‎ | r107946 | r107947 >
Date:21:53, 3 January 2012
Author:krinkle
Status:ok
Tags:
Comment:
[JSTesting] Fix static html tests
* r107919 merge broke it as it removed all the inline mw.config calls, and the tearDown is resetting them to the initial values. That works fine on a MediaWiki page but on the static page are now no variables at all. Copying a basic sample to it. This should've been in the static test suite all along actually.
* Calculating wgScriptPath based on location.pathname instead of location.href, exclude wgServer
* Follows-up r107919
Modified paths:
  • /trunk/phase3/tests/qunit/index.html (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/index.html
@@ -11,8 +11,18 @@
1212 mw.config = new mw.Map( false );
1313
1414 /**
15 - * Guess wgScriptPath (for access to /tests/qunit/data/)
 15+ * Simulate an average mw.config context
1616 */
 17+ /* StartUp module */
 18+ mw.config.set({"wgLoadScript": "/mw/trunk/phase3/load.php", "debug": true, "skin": "vector", "stylepath": "/mw/trunk/phase3/skins", "wgUrlProtocols": "http\\:\\/\\/|https\\:\\/\\/|ftp\\:\\/\\/|irc\\:\\/\\/|ircs\\:\\/\\/|gopher\\:\\/\\/|telnet\\:\\/\\/|nntp\\:\\/\\/|worldwind\\:\\/\\/|mailto\\:|news\\:|svn\\:\\/\\/|git\\:\\/\\/|mms\\:\\/\\/|\\/\\/", "wgArticlePath": "/mw/trunk/phase3/index.php/$1", "wgScriptPath": "/mw/trunk/phase3", "wgScriptExtension": ".php", "wgScript": "/mw/trunk/phase3/index.php", "wgVariantArticlePath": false, "wgActionPaths": [], "wgServer": "http://localhost", "wgUserLanguage": "en", "wgContentLanguage": "en", "wgVersion": "1.19alpha", "wgEnableAPI": true, "wgEnableWriteAPI": true, "wgDefaultDateFormat": "dmy", "wgMonthNames": ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], "wgMonthNamesShort": ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], "wgMainPageTitle": "Main Page", "wgFormattedNamespaces": {"-2": "Media", "-1": "Special", "0": "", "1": "Talk", "2": "User", "3": "User talk", "4": "Testopedia", "5": "Testopedia talk", "6": "File", "7": "File talk", "8": "MediaWiki", "9": "MediaWiki talk", "10": "Template", "11": "Template talk", "12": "Help", "13": "Help talk", "14": "Category", "15": "Category talk"}, "wgNamespaceIds": {"media": -2, "special": -1, "": 0, "talk": 1, "user": 2, "user_talk": 3, "testopedia": 4, "testopedia_talk": 5, "file": 6, "file_talk": 7, "mediawiki": 8, "mediawiki_talk": 9, "template": 10, "template_talk": 11, "help": 12, "help_talk": 13, "category": 14, "category_talk": 15, "image": 6, "image_talk": 7, "project": 4, "project_talk": 5}, "wgSiteName": "Testopedia", "wgFileExtensions": ["png", "gif", "jpg", "jpeg"], "wgDBname": "mediawiki", "wgFileCanRotate": true, "wgAvailableSkins": {"chick": "Chick", "cologneblue": "CologneBlue", "modern": "Modern", "monobook": "MonoBook", "myskin": "MySkin", "nostalgia": "Nostalgia", "simple": "Simple", "standard": "Standard", "vector": "Vector"}, "wgExtensionAssetsPath": "/mw/trunk/phase3/extensions", "wgCookiePrefix": "mediawiki", "wgResourceLoaderMaxQueryLength": -1, "wgCaseSensitiveNamespaces": []});
 19+
 20+ /* WikiPage specific */
 21+ mw.config.set({"wgCanonicalNamespace": "", "wgCanonicalSpecialPageName": false, "wgNamespaceNumber": 0, "wgPageName": "Sandbox", "wgTitle": "Sandbox", "wgCurRevisionId": 486, "wgArticleId": 84, "wgIsArticle": true, "wgAction": "view", "wgUserName": null, "wgUserGroups": ["*"], "wgCategories": [], "wgBreakFrames": false, "wgPageContentLanguage": "en", "wgSeparatorTransformTable": ["", ""], "wgDigitTransformTable": ["", ""], "wgRestrictionEdit": [], "wgRestrictionMove": [], "wgRedirectedFrom": "Sandbox"});
 22+
 23+ /**
 24+ * Fix wgScriptPath and the like to the real thing,
 25+ * instead of fake ones (for access to /tests/qunit/data/)
 26+ */
1727
1828 // Regular expression to extract the path for the QUnit tests
1929 // Takes into account that tests could be run from a file:// URL
@@ -20,14 +30,21 @@
2131 var rePath = /(?:[^#\?](?!index.html))*\/?/;
2232
2333 // Extract path to /tests/qunit/
24 - var qunitTestsPath = rePath.exec( location.href )[0];
 34+ var qunitTestsPath = rePath.exec( location.pathname )[0];
2535
2636 // Traverse up to script path
2737 var pathParts = qunitTestsPath.split( '/' );
2838 pathParts.pop(); pathParts.pop(); pathParts.pop();
2939 var scriptPath = pathParts.join( '/' );
3040
31 - mw.config.set( 'wgScriptPath', scriptPath );
 41+ mw.config.set({
 42+ "wgScriptPath": scriptPath,
 43+ "wgLoadScript": scriptPath + '/load.php',
 44+ "stylepath": scriptPath + '/skins',
 45+ "wgArticlePath": scriptPath + '/index.php/$1',
 46+ "wgScript": scriptPath + '/index.php',
 47+ "wgExtensionAssetsPath": scriptPath + '/extensions'
 48+ });
3249 }
3350 </script>
3451

Follow-up revisions

RevisionCommit summaryAuthorDate
r107949[JSTesting] Fix static html tests...krinkle22:16, 3 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107919merge JSTesting branch into trunk...hashar18:33, 3 January 2012

Status & tagging log