Commit graph

26 commits

Author SHA1 Message Date
Stephan Gambke
514bdd184d Set default type attribute for button html elements
According to standard the default type for <button> elements is "submit". Depending on compatibility mode IE might use "button", instead.
To work around the IE bug this patch forces the standard "submit", if nothing is specified explicitly.

See remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx :
-----
The default value of the type attribute depends on the current document compatibility mode. The default value is submit. In other compatibility modes the default value is button.
...
Windows Internet Explorer 8 and later. The default value of the type attribute depends on the current document compatibility mode. In IE8 Standards mode, the default value is submit.
In other compatibility modes and earlier versions of Windows Internet Explorer, the default value is button.
-----

Change-Id: I3b97a8cac74bbfca63699dfcbf1cc5e9a2cef193
2012-10-30 21:45:17 +01:00
Timo Tijhof
d1c8bf85f8 Fix HtmlTest, XmlTest; Add setMwGlobals method to base TestCase.
The HTML and XML test now set the globals they depend on
(instead of relying on the default settings).

Tests for the "other" scenarios still exist, globals are
overridden inline. They are automatically restored after each
test## function by PHPUnit from MediaWikiTestCase::tearDown.

Also fixed 2 other problems with the test suite:

* HtmlTest::testDropDefaults forgot to pass
  $message to the assertion from the provider ($case[3]).

* The data provider for HtmlTest::testDropDefaults was calling
  Html::element directly (instead of calling it within the test)
  which is problematic because data providers are expected to be
  static. PHPUnit calls them outside the setUp/tearDown flow.
  (also fixed the function to be public static, as PHPUnit
  expects).

That last one was crucial to make the test still pass correctly.

Updated the expected strings to what they are with these
fixed non-leakage settings.

Took wgHtml5 without xmlform as default. And added tests
for variations where it made sense.

Change-Id: Iccf6ea81f4bc2639273ab2ad101c58788ee49d45
2012-10-09 00:26:52 +02:00
jeroendedauw
37d9c1a6dc Fix behaviour of namespaceSelector to match the documentation
Change-Id: I3d1bb232905095ae2d5177adc225025178d5f5a3
2012-10-05 16:19:03 +02:00
Platonides
b8f1c3c69c Change case to use the canonical names.
Change-Id: Ib2640e608ac4d33871446b15fca3780eb7715f1d
2012-09-18 22:30:38 +02:00
Antoine Musso
1a7da4f625 test: full coverage of Html::dropDefaults()
This closely match Html::dropDefaults() logic and hopefully test out
all default dropping.

Introduce a test case that match a failure in f34547ab where attribute
default values passed in an array are not cleaned up.

Change-Id: If8d16b066015ed1bcaf38408511ac3713eaa6540
2012-09-14 21:26:56 -07:00
Daniel Friesen
81f1cace4c Fix broken value="" stripping for HTML5
The default value for value="" on <input> elements is not always an
empty string.

In particular the default value for type="radio" is "on" and by
stripping value="" out of the attributes a "" becomes "on" and our
cleanup code ends up breaking forms.

Change-Id: Ibe5a3be3f45a2f93ef95dbe42729b8f8c94a41cb
2012-09-14 21:26:56 -07:00
Antoine Musso
a45e20ff11 HTML5 new types for input element
HTML5 introduced new types for the input element. For some reasons we
never added them to Html::openElement which would thus strip them even
in HTML5 mode.

The issue is:
 $wgHtml5 = true;
 Html::element( 'input', array( 'type' => 'color' );
 # -> "<input />"

With this patch, we returns: <input type="color" />

Change-Id: I7de373635d0eb47f788d1d664c3a913c8801efd6
2012-09-14 21:26:55 -07:00
Antoine Musso
9fd8cf88f0 tests: Wraper to set/disable $wgHTML5 in HtmlTest
Would let us easily set $wgHtml5 in our tests.

Change-Id: Iacf38c2961cbbb9cc58cd45bba34f10ee5688605
2012-08-30 12:20:31 +02:00
Krinkle
1e5689852b [Html::namespaceSelector] Remove default id/name attributes
* Remove default id/name attributes
* Remove now redundant tests introduced in r110274
* Add tests to make sure label has no 'for' attribute when label isn't null but name/id are unset
* Update tests to not include id="" and name="" when calling with no arguments
* Updating calls to add name/id if needed, and while at it remove useless 'null' params


* Context:
-- Introduced in r109990, r111376, r111315
-- No callers exist that assume these defaults. Forcing an ID that should be unique is annoying and redundant. The name used in the query when submitting a form should be mentioned in the same file where it is used from the submission, never assume what name="" is from unrelated code
-- Same for ID, this is often used in CSS or JavaScript, shouldn't be assumed. (It should be simple to but two simple namespace selectors on a page without getting DOM conflicts)
2012-03-07 19:14:20 +00:00
Sam Reed
8e78fbe32b Cleanup a few unused globals 2012-02-16 02:35:48 +00:00
Antoine Musso
51dacc9fbf split ns selector tests for filter / disable options
ping r111376
2012-02-14 09:59:59 +00:00
Krinkle
78c157faf9 [Html] Follow-up r109990: Add support for excluding and disabling options 2012-02-13 15:08:26 +00:00
Krinkle
8a5c2c6026 [Html] Follow-up r109990: Add category to example namespaces
- Category is a special case since it is not moveable  by default, useful to keep in the test
2012-02-13 14:53:40 +00:00
Aaron Schulz
1bebf0c7ea Fixed windows-related test failures (that string format doesn't work with \r\n line endings as the \r chars are left in the PHP string). 2012-02-02 18:42:02 +00:00
Antoine Musso
9755d2e5aa test Html::namespaceSelector() id & name attributes generation
Method was introduced by r109990.
2012-01-30 10:39:51 +00:00
Chad Horohoe
e8da212569 Fixup r109698, add setter for $namespaceNames and use proper accessors in the tests.
Since we're here: nothing uses $namespaceNames, $mNamespaceIds or $namespaceAliases
outside of this class (core or extensions) so lets make it protected.
2012-01-27 13:00:26 +00:00
Krinkle
3065ece7a2 Fix broken unit test
* r109993 broke the test by overwriting namespaces it tried to preserve
* tearDown should always have the opposite order of the overrides in setUp
* Adding wgLanguageCode while at it, no reason not to, just in case.

-- Follows-up r109993
2012-01-25 03:45:01 +00:00
Krinkle
3c9d05055b [Html] Unit test + bugfix Html::namespaceSelector
* Previously it was passing $selectAttribs['name'] to Xml::label, which uses its value for the <label for=""> attribute. This works as long as $selectAttribs['id'] and $selectAttribs['name'] match, but when they don't it fails. <label for=""> always corresponds with <{input,text area,select} id=""> in browsers, never with "name".
* Make name/id match eachother by default to avoid backwards compatibility breakages (they used to match in the Xml class method as well)
* Add HtmlTest.php entries similar to the ones in XmlTest
* Fix E_NOTICE about $params['selected'], default to ''

-- Follows-up r109974, r109698, r109990
-- Bug originally introduced in r41425
-- XmlTest.php still runs successfully
-- HtmlTest.php runs successfully
2012-01-25 03:25:54 +00:00
Platonides
7d626b347b Use canonical case 2011-10-27 15:54:49 +00:00
Antoine Musso
9a2dc2d05a Tests for r96188 features
That revision let us pass an array of values to 'class', 'rel'
and 'accesskey'. The revision requested some tests :)
2011-10-24 17:45:45 +00:00
Krinkle
73db9698a3 Html.php: The "future"[1] is here. Add features for space-separated value attributes of html elements.
* Has been suggested since August 2009 in r54767 (doc-comment from rawElement/element function)
* Implements normalization for these attributes (removal of duplicates and redundant space)
* Adds support for arrays (instead of just string) for these attributes. 
* String are still supported, and are converted to arrays to get the same normalization.
* Wrote unit tests (which pass locally: $ php phpunit.php includes/HtmlTest.php)
* Not trigger for the media-attribute. Reason: Although some people think it's space-separated, it's actually comma-separated. Treating them as space separated might even destroy the value. [2] [3]. Neither the html4 or html5 spec documents media-attribute as space-separated, and as of HTML5/CSS3 the media attribute may contain "media queries".


[1] "In the future, other HTML-specific features might be added, like allowing arrays for the values of attributes like class= and media=" in r54767 by Simetrical.
[2] http://www.w3.org/TR/1999/REC-html401-19991224/types.html#h-6.13
[3] http://dev.w3.org/csswg/css3-mediaqueries/#background

Implementation note: I choose to have a single list of attributes that trigger this feature. Some of these attributes only support multiple values and/or are documented as space-separated as of html5 (such as accesskey), but since those attributes in general have existed in html4 as well (just different w3c spec), they are not stripped if wgHtml5 is not true. So if this feature would (eg. for accesskey) would only be done if wgHtml5=true, then people could get output like <a accesskey=Array /> depending on a configuration variable, which will get messy and make developers' life hard.
2011-09-03 03:55:23 +00:00
Krinkle
16caaa881a Whitespacing in HtmlTest.php 2011-09-03 01:42:43 +00:00
Alexandre Emsenhuber
1455fe4e21 $wgLanguageCode applies to $wgContLang, not $wgLang. This was breaking the test suite by dying with a "nooo!" in when reaching LanguageConverterTest. 2011-08-05 15:10:08 +00:00
Platonides
a326e60e48 Follow-up r92588. Make it work regardless of $wgHtml5 2011-07-19 22:10:05 +00:00
Platonides
a2251d34f9 Follow up r91419. A boolean attribute can be both the empty string and its name [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attributes]
We use the later since that's what xhtml1 required [http://www.w3.org/TR/xhtml1/#h-4.5].
2011-07-19 21:38:28 +00:00
Antoine Musso
2801589462 tests for Html::testExpandAttributes()
FIXME: seems a code duplication of Xml::expandAttributes()

follow up r81571 (skip attributes with null value)
2011-07-04 19:51:35 +00:00