Commit graph

447 commits

Author SHA1 Message Date
Bartosz Dziewoński
3987b10b51 CSSMin: Fix remapOne() for URLs that are proto-relative or have query part
Bug: 58338
Change-Id: I836a2c054ae3edc07895b2388f4ec8663223347a
2013-12-11 20:58:28 +01:00
Bartosz Dziewoński
f3779e067f Rewrite CSSMin::remap to support multiple url() values in one rule
Each can be selectively embedded by placing the /* @embed */ comment
just before the url() value. /* @embed */ at the beginning of the rule
affects all url() values appearing in it.

Three changes in existing behavior for previously supported syntax:
* /* @embed */ comments are no longer preserved in output
* rules not terminated by semicolons are correctly supported
* spaces within url() values are correctly supported

Bug: 46757
Bug: 56514
Change-Id: If9082f553fa920c606f12093f39f4a163ebacc32
2013-11-29 18:23:33 +00:00
Bartosz Dziewoński
cdcf0d5ed7 More tests for CSSMin::remap
Also added commented-out tests which should work, but don't.
Making them work in subsequent patch If9082f55.

Change-Id: I65f62493e6d10e7e90af8844f8a26e3982d75f51
2013-11-29 18:19:23 +00:00
addshore
749599fc3c @covers tags for unit tests
Change-Id: I2b486b38326bf23bd379efba2142034e24c0745f
2013-10-24 18:22:57 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
addshore
17c1e91238 General cleanup of Parser tests
- Fixes scope
 - Adds covers tags

Change-Id: I6024f2f7cc7a1812a417c6c389b0a15addde0b5e
2013-10-23 12:26:15 +00:00
jenkins-bot
edba2e008c Merge "CSSJanus: Support text-shadow and box-shadow flipping" 2013-09-27 20:35:16 +00:00
Tim Starling
ab6758a697 SECURITY: Fix extension detection with 2 .'s
Fix IE6 extension detection, to prevent XSS in the API response.

Bug: 52746
Change-Id: If58a81b62209b36bd143a1766a8a20c9c34dbe3b
2013-09-03 22:10:31 +00:00
Ebrahim Byagowi
bda65740a8 Tweak CSSJanus to support noflip for selectors with parentheses
Also suggested for CSSJanus itself at http://code.google.com/p/cssjanus/issues/detail?id=22

Change-Id: I4e3b21522e9c5a72cd456ed3d6a0be9225e4b70d
2013-07-19 11:53:27 -07:00
MatmaRex
511273dca1 CSSJanus: Support text-shadow and box-shadow flipping
We just need to negate the horizontal offset value in both of them.

This only supports *a single shadow* per element; multiple shadows
are not supported (only the first will be flipped).

Second attempt. First, reverted one: I14822955.

Bug: 45677
Change-Id: I97ee7431e1a5acb35d594076a88a0f9acf290402
2013-07-17 20:30:24 +02:00
MatmaRex
ad6d2e43d5 CSSJanus: Handle values of border-radius correctly
The values are not "top right bottom left" here, but
"top-left top-right bottom-right bottom-left".

Bug: 49074
Change-Id: I22bc777b59e667aeb36727fdc8e41e8681979128
2013-07-17 12:47:10 +02:00
MatmaRex
b5984db716 CSSJanus: Fix handling of CSS3 color syntaxes
The 'color' rule, and by extension 'four_notation_color' too,
only understood #rrggbb and named colors. Extend it to match
rgb[a](...) and hsl[a](...) syntaxes as well.

This makes usage of rgb(a)/hsl(a) syntax in declarations like
'border-color: a b c d;' be interpreted and flipped correctly.

Change-Id: I218a9aa55a86b3d955b92375c1a209fdde312138
2013-07-04 05:30:26 +02:00
MatmaRex
3eaad66d63 CSSJanus: don't mangle 5+ consecutive numeric values
Don't mangle 5+ consecutive numeric values in the
'four_notation_quantity' and 'four_notation_color' rules. This
prevents box-shadow rules from being utterly broken in RTL (but still
doesn't flip them properly).

Bug: 45677
Change-Id: I16cb9e171a79c6f299b40fa02908b0c045e3c474
2013-06-06 17:29:51 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
Krinkle
d86c886ac6 Revert "(bug 45677) CSSJanus: support text-shadow and box-shadow flipping"
See I5d24c7d8456e2. This is a wontfix per Trevor and myself.

This reverts commit e457d804eb

Change-Id: I886a078cbeedd5a742e9c6dfedc9bd718bab089c
2013-03-07 06:19:26 +00:00
MatmaRex
e457d804eb (bug 45677) CSSJanus: support text-shadow and box-shadow flipping
We just need to negate the horizontal offset value in both of them.

This only supports *a single shadow* per element; multiple shadows
are not supported (only the first will be flipped).

Also, to make it possible:
* don't mangle 5+ consecutive numeric values in the
  'four_notation_quantity' rule
* support rgb(a) and hsl(a) colors in the 'color' rule

Change-Id: I148229558e1b9a0516e413ffe86007235c3c3ef8
2013-03-05 20:42:52 +01:00
Siebrand Mazeland
de04f37ef1 Update formatting
5 of n.

Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
2013-02-15 12:35:50 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Tim Landscheidt
ce034ac430 Do not flip partial keys in CSSJanus.
Change-Id: I1ee9d16069c4627aa81024eeb642714ef796cec5
2013-01-23 07:57:07 +00:00
jeroendedauw
9e4761e3aa Fixed SiteArray serialization
Change-Id: I9844236b8720d96f99aef788ab023c522f993045
2012-12-12 20:00:03 +01:00
Platonides
3118c450e4 Remove the \ before the class name.
Then 'stdclass' is preceded by T_NEW and taken as a class name.
Else it was misinterpreted as a function call.

Change-Id: Ib6afccb26e530a24bf7414ede10f573a9934d2ed
2012-12-11 00:08:41 +01:00
jeroendedauw
d528767567 Remove broken test.
Calling the method does not raise an exception but a notice (depending on settings).
PHPUnit just happens to turn this into an exception. The test thus breaks if PHPUnit
does not do this, which apparently happens in some cases and caused bug 41491

Change-Id: I9d14fd875c70c8b3d164c0b8a4fa2667c5769682
2012-12-08 19:26:40 +01:00
jeroendedauw
7389d7c690 Added sites functionality, a much more generic and flexible version of the existing interwiki code
This code is meant to replace the current interwiki code, but does not do so just yet. It is however used by the Wikibase extension. This allows us to try out some more things and have the code stabilize more before we migrate over existing interwiki functionality.

Change-Id: I23c47c2c3909a1500350fb560a5f2ec654e2c37e
2012-10-12 17:47:44 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
jeroendedauw
4a2e4e569a Added default implmentation of instanceProvider to GenericArrayObjectTest
Change-Id: I8d77c03b90ddca226c4bff18e42c53980bf9a861
2012-08-29 19:52:13 +02:00
jeroendedauw
11d290fe7b use InvalidArgumentException rather then Exception
Change-Id: Ie744c773b316278e4a92af28354a8fe4eb83b78f
2012-08-27 13:34:02 +02:00
jeroendedauw
1bc7295296 Fix type of exception no longer matching after someone changed it without running the tests...
Change-Id: I5b1c3556f40d869f0f5d4a617f01f981d607d11f
2012-08-24 21:10:45 +02:00
jeroendedauw
afe46f1403 Added GenericArrayObject class and associated test base
Change-Id: Id7e9b59c7ed4a9338744db58935307ecb4bc441f
2012-08-13 20:18:48 -07:00
Timo Tijhof
663f947b7b (bug 27395) Write PHPUnit test suite for CSSJanus
Change-Id: If40c5de54bffae6e5ac8fac81754a53a40c652b1
2012-07-31 13:09:35 -07:00
Hashar
6e9ebaf9cc Merge "JavaScriptMinifierTest: Increase test coverage" 2012-06-25 13:53:14 +00:00
Timo Tijhof
41759f322c PHP test suite for CSSMin
Change-Id: Ic9195614acfd616ccdff57cfc666aa4dfa71fb96
2012-06-20 14:28:09 +02:00
Timo Tijhof
c33087beaa JavaScriptMinifierTest: Increase test coverage
* Per https://bugzilla.wikimedia.org/show_bug.cgi?id=27395#c1
  adding test cases for things that broke in the past:
  - bug 26931
  - bug 27046

* Added various other small tests that seem fitting in their context

* Moved testBug32548Exponent to below the data provider (like most
  other tests iirc).

Change-Id: I7a4df097108ec05bc58d5a110329e13ff9587c8a
2012-06-20 05:18:39 +02:00
Brion Vibber
e97346ec18 Revert r103978, r103979 -- screwed something up, breaks jQuery minification.
Incremented ResourceLoader::filterCacheVersion rather than decrementing to avoid potential confusion, especially since we already needed the incr.
2011-11-23 00:22:46 +00:00
Brion Vibber
6b06770b6d Followup r103865 and r103915
r103915 added a parse error for 'more than 2 decimal points' in a number; this is the wrong place to check for that. Should only check whether there's more digits or identifier chars -- identifier chars would be illegal.

Added test cases for the exponent missing fails, tweaked it to be more consistent (only need to check for one e; if we have more we can lump them in with 'not digits' :)


Also cleaned up no-longer-needed suppress/restore warnings around JS parser invocation
2011-11-22 23:10:22 +00:00
Platonides
a82a7940f6 Final fixup to r103910 and follow-ups.
Reverts r103931 test change.
2011-11-22 18:56:55 +00:00
Platonides
6cac97e88c Two decimal points may be valid, as 5..toString() == (5.).toString()
Added some tests
2011-11-22 18:42:21 +00:00
Platonides
b23dc2f758 Follow-up r103915: We need to increment $end before the strcspn.
Adjusting the tests, since it is now adding the newline after the number.
2011-11-22 18:10:25 +00:00
Brion Vibber
8bf802734c Add PHPUnit tests for the minification failure case in bug 32548.
This will trigger 2 test failures, where an exponent in a JS numeric literal gets split over line breaks at the '-' or '+', causing a parse error in the resulting output.
A number with the same string length but without using + or - in the exponent passes through fine, indicating that it's the -/+ that's getting misinterpreted.
2011-11-21 22:20:06 +00:00
Brion Vibber
72ba305da4 * (bug 31187) Fix for user JavaScript validation to allow identifiers with valid Unicode letter characters
Followup r91591, r93020: patch to jsminplus to support Unicode chars and char escapes in identifiers

Fast-path check keeps runtime about the same on most scripts (eg jquery.js parsing was abround 4100ms both before and after on my test machine)
Slow-path code kicks in if plain ASCII word chars don't extend all the way to the next whitespace or punctuation char.
Using PCRE's Unicode properties magic to ensure that we're catching everything, following ECMA-262 edition 5.1 spec.

Note that identifiers using escapes don't get normalized to their UTF-8 form; this might be a nice thing to do as it saves a couple bytes, but currently there's no change made to output.


Added QUnit tests to verify that unicode letter & escapes work in identifiers in all supported browsers (ok back to IE 6, yay)
2011-09-27 22:51:36 +00:00
Brion Vibber
12ccca0349 Followup r83885: add JSMin+ 1.3 to use its parser to verify output of JavaScriptMinifierTest unit test cases. Had to change some of the test cases because they were not valid JavaScript programs -- one of the quoting tests was incorrectly quoted in the PHP sources, and several tests around return, continue, and break keywords failed due to not using them in the contexts that they require.
http://crisp.tweakblogs.net/blog/1856/jsmin+-version-13.html
JSMin+ under MPL 1.1/ GPL 2.0 / LGPL 2.1 license.
2011-07-06 20:02:10 +00:00
Tim Starling
d5294e3b73 Test filename updates for r89558. 2011-06-06 12:00:57 +00:00
Max Semenik
f7c1ecc5ee Removed JavaScriptDistiller: unused 2011-04-19 10:13:25 +00:00
Roan Kattouw
27508f06af Followup r83891: don't insert a newline before ++ or -- . Patch by Paul Copperman 2011-03-14 18:04:39 +00:00
Roan Kattouw
5ce4ecfced Per Nikerabbit, add some minifier tests for historic failure cases that I had lying around 2011-03-14 13:55:42 +00:00
Roan Kattouw
867fc1cba8 (bug 27528) Incorporate Paul Copperman's minifier 2011-03-14 11:44:33 +00:00
Max Semenik
5875959e25 Very basic JavaScriiptDistiller tests, needs serious expansion 2011-02-23 08:06:11 +00:00