diff options
author | James Graham <james@hoppipolla.co.uk> | 2015-03-27 09:18:12 +0000 |
---|---|---|
committer | James Graham <james@hoppipolla.co.uk> | 2015-04-03 23:29:19 +0100 |
commit | 2c9faf5363be229498578bdeca55c0c52730f0fa (patch) | |
tree | e070d5d12a587f1e1939410b2cd88450543d7534 /tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support | |
parent | 1a81b18b9f22d7bc1a967d08fcc7fbcf2ee200f5 (diff) | |
download | servo-2c9faf5363be229498578bdeca55c0c52730f0fa.tar.gz servo-2c9faf5363be229498578bdeca55c0c52730f0fa.zip |
Update CSS tests to revision 31d63cc79bd4c929ed582229e936d7b389f3e6ab
Diffstat (limited to 'tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support')
49 files changed, 1065 insertions, 0 deletions
diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-green.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-green.png Binary files differnew file mode 100644 index 00000000000..b98ca0ba0a0 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-green.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-lime.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-lime.png Binary files differnew file mode 100644 index 00000000000..cb397fb090e --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-lime.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-maroon.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-maroon.png Binary files differnew file mode 100644 index 00000000000..3f86b072195 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-maroon.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-navy.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-navy.png Binary files differnew file mode 100644 index 00000000000..9b9a03955ba --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-navy.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-red.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-red.png Binary files differnew file mode 100644 index 00000000000..6bd73ac1018 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-red.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-white.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-white.png Binary files differnew file mode 100644 index 00000000000..dd43faec54a --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/1x1-white.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-gg-rr.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-gg-rr.png Binary files differnew file mode 100644 index 00000000000..84f5b2a4f1d --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-gg-rr.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-green.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-green.png Binary files differnew file mode 100644 index 00000000000..b3c8cf3eb4c --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-green.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-red.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-red.png Binary files differnew file mode 100644 index 00000000000..823f125b8e4 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/60x60-red.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/README b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/README new file mode 100644 index 00000000000..69d1737bead --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/README @@ -0,0 +1,29 @@ +CSS Global Support Directory +============================ + +This directory contains common support files (such as images and external +style sheets). These are sync'ed into the support directories of all our +test suites. If you have test-suite-specific support files, please add +them to the appropriate test-suite-specific support/ directory. + +If you add to a support/ directory, please run the tools/supportprop.py +script from the top of the repository to cascade support files into the +lower-level support directories. + +Description of the Common Support File Collection +------------------------------------------------- + +The 1x1-* images are all exactly one pixel. + +The swatch-* images all use 15x15 cells. + +The square-* images all use 15x15 cells with one pixel borders. + +The pattern-* images use cells of various sizes: + + pattern-gg-gr.png 20x20 + pattern-grg-rgr-grg.png 20x20 + pattern-rgr-grg-rgr.png 20x20 + pattern-tr.png 15x15 + pattern-grg-rrg-rgg.png 15x15 + diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/a-green.css b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/a-green.css new file mode 100644 index 00000000000..b0dbb071d5b --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/a-green.css @@ -0,0 +1 @@ +.a { color: green; } diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/b-green.css b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/b-green.css new file mode 100644 index 00000000000..a0473f5ca26 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/b-green.css @@ -0,0 +1 @@ +.b { color: green; }
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/c-red.css b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/c-red.css new file mode 100644 index 00000000000..d4ba5c64e95 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/c-red.css @@ -0,0 +1 @@ +.c { color: red; }
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/cat.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/cat.png Binary files differnew file mode 100644 index 00000000000..85dd7324815 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/cat.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/generalParallelTest.js b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/generalParallelTest.js new file mode 100644 index 00000000000..c7853c3e65f --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/generalParallelTest.js @@ -0,0 +1,229 @@ +(function(root) { +'use strict'; +// +var index = 0; +var suite = root.generalParallelTest = { + // prepare individual test + setup: function(data, options) { + suite._setupDom(data, options); + suite._setupEvents(data, options); + }, + // clone fixture and prepare data containers + _setupDom: function(data, options) { + // clone fixture into off-viewport test-canvas + data.fixture = document.getElementById('fixture').cloneNode(true); + data.fixture.id = 'test-' + (index++); + (document.getElementById('offscreen') || document.body).appendChild(data.fixture); + + // data container for #fixture > .container > .transition + data.transition = { + node: data.fixture.querySelector('.transition'), + values: [], + events: [], + computedStyle: function(property) { + return computedStyle(data.transition.node, property); + } + }; + + // data container for #fixture > .container + data.container = { + node: data.transition.node.parentNode, + values: [], + events: [], + computedStyle: function(property) { + return computedStyle(data.container.node, property); + } + }; + + // data container for #fixture > .container > .transition[:before | :after] + if (data.pseudo) { + data.pseudo = { + name: data.pseudo, + values: [], + computedStyle: function(property) { + return computedStyle(data.transition.node, property, ':' + data.pseudo.name); + } + }; + } + }, + // bind TransitionEnd event listeners + _setupEvents: function(data, options) { + ['transition', 'container'].forEach(function(elem) { + data[elem]._events = addTransitionEvent(data[elem].node, function(event) { + event.stopPropagation(); + var name = event.propertyName; + var time = Math.round(event.elapsedTime * 1000) / 1000; + var pseudo = event.pseudoElement ? (':' + event.pseudoElement) : ''; + data[elem].events.push(name + pseudo + ":" + time + "s"); + }); + }); + }, + // cleanup after individual test + teardown: function(data, options) { + // data.fixture.remove(); + if (data.fixture.parentNode) { + data.fixture.parentNode.removeChild(data.fixture); + } + }, + // invoked prior to running a slice of tests + sliceStart: function(options, tests) { + // inject styles into document + setStyle(options.styles); + // kick off value collection loop + generalParallelTest.startValueCollection(options); + }, + // invoked after running a slice of tests + sliceDone: function(options, tests) { + // stop value collection loop + generalParallelTest.stopValueCollection(options); + // reset styles cache + options.styles = {}; + }, + // called once all tests are done + done: function(options) { + // reset document styles + setStyle(); + reflow(); + }, + // add styles of individual test to slice cache + addStyles: function(data, options, styles) { + if (!options.styles) { + options.styles = {}; + } + + Object.keys(styles).forEach(function(key) { + var selector = '#' + data.fixture.id + // fixture must become #fixture.fixture rather than a child selector + + (key.substring(0, 8) === '.fixture' ? '' : ' ') + + key; + + options.styles[selector] = styles[key]; + }); + }, + // set style and compute values for container and transition + getStyle: function(data) { + reflow(); + // grab current styles: "initial state" + suite._getStyleFor(data, 'from'); + // apply target state + suite._addClass(data, 'to', true); + // grab current styles: "target state" + suite._getStyleFor(data, 'to'); + // remove target state + suite._removeClass(data, 'to', true); + + // clean up the mess created for value collection + data.container._values = []; + data.transition._values = []; + if (data.pseudo) { + data.pseudo._values = []; + } + }, + // grab current styles and store in respective element's data container + _getStyleFor: function(data, key) { + data.container[key] = data.container.computedStyle(data.property); + data.transition[key] = data.transition.computedStyle(data.property); + if (data.pseudo) { + data.pseudo[key] = data.pseudo.computedStyle(data.property); + } + }, + // add class to test's elements and possibly reflow + _addClass: function(data, className, forceReflow) { + data.container.node.classList.add(className); + data.transition.node.classList.add(className); + if (forceReflow) { + reflow(); + } + }, + // remove class from test's elements and possibly reflow + _removeClass: function(data, className, forceReflow) { + data.container.node.classList.remove(className); + data.transition.node.classList.remove(className); + if (forceReflow) { + reflow(); + } + }, + // add transition and to classes to container and transition + startTransition: function(data) { + // add transition-defining class + suite._addClass(data, 'how', true); + // add target state (without reflowing) + suite._addClass(data, 'to', false); + }, + // requestAnimationFrame runLoop to collect computed values + startValueCollection: function(options) { + var raf = getRequestAnimationFrame() || function(callback){ + setTimeout(callback, 20); + }; + + // flag denoting if the runLoop should continue (true) or exit (false) + options._collectValues = true; + + function runLoop() { + if (!options._collectValues) { + // test's are done, stop annoying the CPU + return; + } + + // collect current style for test's elements + options.tests.forEach(function(data) { + if (!data.property) { + return; + } + + ['transition', 'container', 'pseudo'].forEach(function(elem) { + var pseudo = null; + if (!data[elem] || (elem === 'pseudo' && !data.pseudo)) { + return; + } + + var current = data[elem].computedStyle(data.property); + var values = data[elem].values; + var length = values.length; + if (!length || values[length - 1] !== current) { + values.push(current); + } + }); + }); + + // rinse and repeat + raf(runLoop); + } + + runLoop(); + }, + // stop requestAnimationFrame runLoop collecting computed values + stopValueCollection: function(options) { + options._collectValues = false; + }, + + // generate test.step function asserting collected events match expected + assertExpectedEventsFunc: function(data, elem, expected) { + return function() { + var _result = data[elem].events.sort().join(" "); + var _expected = typeof expected === 'string' ? expected : expected.sort().join(" "); + assert_equals(_result, _expected, "Expected TransitionEnd events triggered on ." + elem); + }; + }, + // generate test.step function asserting collected values are neither initial nor target + assertIntermediateValuesFunc: function(data, elem) { + return function() { + // the first value (index: 0) is always going to be the initial value + // the last value is always going to be the target value + var values = data[elem].values; + if (data.flags.discrete) { + // a discrete value will just switch from one state to another without having passed intermediate states. + assert_equals(values[0], data[elem].from, "must be initial value while transitioning on ." + elem); + assert_equals(values[1], data[elem].to, "must be target value after transitioning on ." + elem); + assert_equals(values.length, 2, "discrete property only has 2 values ." + elem); + } else { + assert_not_equals(values[1], data[elem].from, "may not be initial value while transitioning on ." + elem); + assert_not_equals(values[1], data[elem].to, "may not be target value while transitioning on ." + elem); + } + + // TODO: first value must be initial, last value must be target + }; + } +}; + +})(window);
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/helper.js b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/helper.js new file mode 100644 index 00000000000..642ee3435c9 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/helper.js @@ -0,0 +1,122 @@ +// +// Simple Helper Functions For Testing CSS +// + +(function(root) { +'use strict'; + +// serialize styles object and dump to dom +// appends <style id="dynamic-style"> to <head> +// setStyle("#some-selector", {"some-style" : "value"}) +// setStyle({"#some-selector": {"some-style" : "value"}}) +root.setStyle = function(selector, styles) { + var target = document.getElementById('dynamic-style'); + if (!target) { + target = document.createElement('style'); + target.id = 'dynamic-style'; + target.type = "text/css"; + document.getElementsByTagName('head')[0].appendChild(target); + } + + var data = []; + // single selector/styles + if (typeof selector === 'string' && styles !== undefined) { + data = [selector, '{', serializeStyles(styles), '}']; + target.textContent = data.join("\n"); + return; + } + // map of selector/styles + for (var key in selector) { + if (Object.prototype.hasOwnProperty.call(selector, key)) { + var _data = [key, '{', serializeStyles(selector[key]), '}']; + data.push(_data.join('\n')); + } + } + + target.textContent = data.join("\n"); +}; + +function serializeStyles(styles) { + var data = []; + for (var property in styles) { + if (Object.prototype.hasOwnProperty.call(styles, property)) { + var prefixedProperty = addVendorPrefix(property); + data.push(prefixedProperty + ":" + styles[property] + ";"); + } + } + + return data.join('\n'); +} + + +// shorthand for computed style +root.computedStyle = function(element, property, pseudo) { + var prefixedProperty = addVendorPrefix(property); + return window + .getComputedStyle(element, pseudo || null) + .getPropertyValue(prefixedProperty); +}; + +// flush rendering buffer +root.reflow = function() { + document.body.offsetWidth; +}; + +// add all known TransitionEnd events to element +root.addTransitionEvent = function(element, handler) { + return addEvent(element, 'TransitionEnd webkitTransitionEnd transitionend oTransitionEnd otransitionend MSTransitionEnd', handler); +}; + +// add space-separated list of events to element +root.addEvent = function(element, events, handler) { + var _events = {}; + var tokens = events.split(" "); + for (var i = 0, token; token = tokens[i]; i++) { + element.addEventListener(token, handler, false); + _events[token] = handler; + } + return _events; +}; + +// merge objects +root.extend = function(target /*, ..rest */) { + Array.prototype.slice.call(arguments, 1).forEach(function(obj) { + Object.keys(obj).forEach(function(key) { + target[key] = obj[key]; + }); + }); + + return target; +}; + +// dom fixture helper ("resetting dom test elements") +var _domFixture; +var _domFixtureSelector; +root.domFixture = function(selector) { + var fixture = document.querySelector(selector || _domFixtureSelector); + if (!fixture) { + throw new Error('fixture ' + (selector || _domFixtureSelector) + ' not found!'); + } + if (!_domFixture && selector) { + // save a copy + _domFixture = fixture.cloneNode(true); + _domFixtureSelector = selector; + } else if (_domFixture) { + // restore the copy + var tmp = _domFixture.cloneNode(true); + fixture.parentNode.replaceChild(tmp, fixture); + } else { + throw new Error('domFixture must be initialized first!'); + } +}; + +// return requestAnimationFrame handler, if available +root.getRequestAnimationFrame = function() { + return window.requestAnimationFrame + || window.mozRequestAnimationFrame + || window.webkitRequestAnimationFrame + || window.msRequestAnimationFrame + || window.oRequestAnimationFrame; +}; + +})(window);
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-green.css b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-green.css new file mode 100644 index 00000000000..537104e6633 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-green.css @@ -0,0 +1 @@ +.import { color: green; } diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-red.css b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-red.css new file mode 100644 index 00000000000..9945ef47114 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/import-red.css @@ -0,0 +1 @@ +.import { color: red; } diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/one.gif b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/one.gif Binary files differnew file mode 100644 index 00000000000..74cf7839c9f --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/one.gif diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-gg-gr.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-gg-gr.png Binary files differnew file mode 100644 index 00000000000..091de70bb72 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-gg-gr.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rgr-grg.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rgr-grg.png Binary files differnew file mode 100644 index 00000000000..9b88fbd8114 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rgr-grg.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rrg-rgg.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rrg-rgg.png Binary files differnew file mode 100644 index 00000000000..fcf4f3fd7d9 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-grg-rrg-rgg.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-rgr-grg-rgr.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-rgr-grg-rgr.png Binary files differnew file mode 100644 index 00000000000..d454e3a630c --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-rgr-grg-rgr.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-tr.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-tr.png Binary files differnew file mode 100644 index 00000000000..8b4b25364e0 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/pattern-tr.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/properties.js b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/properties.js new file mode 100644 index 00000000000..0ca8fedc05c --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/properties.js @@ -0,0 +1,449 @@ +(function(root){ + +/* + * General Value Types definition + * they return an object of arrays of type { <name>: [<start-value>, <end-value>], ... } + */ +var values = { + 'length' : function() { + // http://www.w3.org/TR/css3-values/#lengths + return { + // CSS Values and Module Level 3 + // ch: ['1ch', '10ch'], + // rem: ['1rem', '10rem'], + // vw: ['1vw', '10vw'], + // vh: ['1vh', '10vh'], + // vmin: ['1vmin', '10vmin'], + // vmax: ['1vmax', '10vmax'], + // CSS Values and Module Level 2 + pt: ['1pt', '10pt'], + pc: ['1pc', '10pc'], + px: ['1px', '10px'], + // CSS Values and Module Level 1 + em: ['1em', '10em'], + ex: ['1ex', '10ex'], + mm: ['1mm', '10mm'], + cm: ['1cm', '10cm'], + 'in': ['1in', '10in'] + }; + }, + 'length-em': function() { + return { + em: ['1.1em', '1.5em'] + }; + }, + 'percentage': function() { + // http://www.w3.org/TR/css3-values/#percentages + return { + '%': ['33%', '80%'] + }; + }, + 'color': function() { + // http://www.w3.org/TR/css3-values/#colors + // http://www.w3.org/TR/css3-color/ + return { + rgba: ['rgba(100,100,100,1)', 'rgba(10,10,10,0.4)'] + }; + }, + 'rectangle': function() { + // http://www.w3.org/TR/CSS2/visufx.html#value-def-shape + return { + rectangle: ['rect(10px,10px,10px,10px)', 'rect(15px,15px,5px,5px)'] + }; + }, + 'font-weight': function() { + // http://www.w3.org/TR/css3-fonts/#font-weight-prop + return { + keyword: ["normal", "bold"], + numeric: ["100", "900"] + }; + }, + 'number': function() { + // http://www.w3.org/TR/css3-values/#number + return { + integer: ["1", "10"], + decimal: ["1.1", "9.55"] + }; + }, + 'number[0,1]': function() { + // http://www.w3.org/TR/css3-values/#number + // applies to [0,1]-ranged properties like opacity + return { + "zero-to-one": ["0.2", "0.9"] + }; + }, + 'integer': function() { + // http://www.w3.org/TR/css3-values/#integer + return { + integer: ["1", "10"] + }; + }, + 'shadow': function() { + // http://www.w3.org/TR/css-text-decor-3/#text-shadow-property + return { + shadow: ['rgba(0,0,0,0.1) 5px 6px 7px', 'rgba(10,10,10,0.9) 5px 6px 7px'] + }; + }, + 'visibility': function() { + // http://www.w3.org/TR/CSS2/visufx.html#visibility + return { + keyword: ['visible', 'hidden', {discrete: true}] + }; + }, + 'auto': function(property) { + var types = properties[property] || unspecified_properties[property]; + var val = values[types[0]](property); + var key = Object.keys(val).shift(); + return { + to: [val[key][1], 'auto'], + from: ['auto', val[key][1]] + }; + }, + // types reqired for non-specified properties + 'border-radius': function() { + return { + px: ['1px', '10px'], + "px-px": ['1px 3px', '10px 13px'] + }; + }, + 'image' : function() { + var prefix = getValueVendorPrefix('background-image', 'linear-gradient(top, hsl(0, 80%, 70%), #bada55)'); + return { + // Chrome implements this + url: ['url(support/one.gif)', 'url(support/two.gif)'], + data: ['url(data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=)', 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==)'], + // A hunch, as from the spec: + // http://www.w3.org/TR/css3-transitions/#animatable-types + // gradient: interpolated via the positions and colors of each stop. They must have the same type (radial or linear) and same number of stops in order to be animated. Note: [CSS3-IMAGES] may extend this definition. + gradient: [prefix + 'linear-gradient(top, hsl(0, 80%, 70%), #bada55)', prefix + 'linear-gradient(top, #bada55, hsl(0, 80%, 70%))'] + }; + }, + 'background-size': function() { + return { + keyword: ['cover', 'contain'] + }; + }, + 'box-shadow': function() { + // http://www.w3.org/TR/css3-background/#ltshadowgt + return { + shadow: ['60px -16px teal', '60px -16px red'] + }; + }, + 'vertical': function() { + return { + keyword: ['top', 'bottom'] + }; + }, + 'horizontal': function() { + return { + keyword: ['left', 'right'] + }; + }, + 'font-stretch': function() { + return { + keyword: ['condensed', 'expanded'] + }; + }, + 'transform': function() { + return { + rotate: ['rotate(10deg)', 'rotate(20deg)'] + }; + }, + 'position': function() { + return { + 'static to absolute': ['static', 'absolute', {discrete: true}], + 'relative to absolute': ['relative', 'absolute', {discrete: true}], + 'absolute to fixed': ['absolute', 'fixed', {discrete: true}] + }; + }, + 'display': function() { + return { + 'static to absolute': ['none', 'block', {discrete: true}], + 'block to inline-block': ['block', 'inline-block', {discrete: true}] + }; + } +}; + +/* + * Property to Type table + * (as stated in specification) + */ +var properties = { + 'background-color': ['color'], + 'background-position': ['length', 'percentage'], + + 'border-top-width': ['length'], + 'border-right-width': ['length'], + 'border-bottom-width': ['length'], + 'border-left-width': ['length'], + + 'border-top-color': ['color'], + 'border-right-color': ['color'], + 'border-bottom-color': ['color'], + 'border-left-color': ['color'], + + 'padding-bottom': ['length'], + 'padding-left': ['length'], + 'padding-right': ['length'], + 'padding-top': ['length'], + + 'margin-bottom': ['length'], + 'margin-left': ['length'], + 'margin-right': ['length'], + 'margin-top': ['length'], + + 'height': ['length', 'percentage'], + 'width': ['length', 'percentage'], + 'min-height': ['length', 'percentage'], + 'min-width': ['length', 'percentage'], + 'max-height': ['length', 'percentage'], + 'max-width': ['length', 'percentage'], + + 'top': ['length', 'percentage'], + 'right': ['length', 'percentage'], + 'bottom': ['length', 'percentage'], + 'left': ['length', 'percentage'], + + 'color': ['color'], + 'font-size': ['length', 'percentage'], + 'font-weight': ['font-weight'], + 'line-height': ['number', 'length', 'percentage'], + 'letter-spacing': ['length'], + // Note: percentage is Level3 and not implemented anywhere yet + // http://dev.w3.org/csswg/css3-text/#word-spacing + 'word-spacing': ['length', 'percentage'], + 'text-indent': ['length', 'percentage'], + 'text-shadow': ['shadow'], + + 'outline-color': ['color'], + // outline-offset <integer> used to be an error in the spec + 'outline-offset': ['length'], + 'outline-width': ['length'], + + 'clip': ['rectangle'], + // Note: doesn't seem implemented anywhere + 'crop': ['rectangle'], + + 'vertical-align': ['length', 'percentage'], + 'opacity': ['number[0,1]'], + 'visibility': ['visibility'], + 'z-index': ['integer'] +}; + +/* + * Property to auto-value mapping + * (lazily taken from http://www.siliconbaytraining.com/pages/csspv.html) + */ +var properties_auto = [ + 'margin-top', + 'margin-right', + 'margin-bottom', + 'margin-left', + 'height', + 'width', + 'clip', + 'marker-offset', + 'top', + 'right', + 'left', + 'bottom', + 'z-index' +]; + +/* + * Property to Type table + * (missing value-types of specified properties) + */ +var missing_properties = { + 'margin-bottom': ['percentage'], + 'margin-left': ['percentage'], + 'margin-right': ['percentage'], + 'margin-top': ['percentage'], + 'padding-bottom': ['percentage'], + 'padding-left': ['percentage'], + 'padding-right': ['percentage'], + 'padding-top': ['percentage'], + 'vertical-align': ['vertical'] +}; + +/* + * Property to Type table + * (properties that haven't been specified but implemented) + */ +var unspecified_properties = { + // http://oli.jp/2010/css-animatable-properties/ + 'border-top-left-radius': ['border-radius'], + 'border-top-right-radius': ['border-radius'], + 'border-bottom-left-radius': ['border-radius'], + 'border-bottom-right-radius': ['border-radius'], + 'background-image': ['image'], + 'background-size': ['background-size'], + // http://dev.w3.org/csswg/css3-background/#the-box-shadow + // Animatable: yes, except between inner and outer shadows (Transition to/from an absent shadow is a transition to/from ‘0 0 transparent’ or ‘0 0 transparent inset’, as appropriate.) + 'box-shadow': ['box-shadow'], + 'font-size-adjust': ['number'], + 'font-stretch': ['font-stretch'], + 'marker-offset': ['length'], + 'text-decoration-color': ['color'], + 'column-count': ['integer'], + 'column-gap': ['length'], + 'column-rule-color': ['color'], + 'column-rule-width': ['length'], + 'column-width': ['length'], + 'transform': ['transform'], + 'transform-origin': ['horizontal'], + 'zoom': ['number'], + 'outline-radius-topleft': ['length', 'percentage'], + 'outline-radius-topright': ['length', 'percentage'], + 'outline-radius-bottomright': ['length', 'percentage'], + 'outline-radius-bottomleft': ['length', 'percentage'], + 'display': ['display'], + 'position': ['position'] +}; + +/* + * additional styles required to actually render + * (different browsers expect different environment) + */ +var additional_styles = { + // all browsers + 'border-top-width': {'border-top-style' : 'solid'}, + 'border-right-width': {'border-right-style' : 'solid'}, + 'border-bottom-width': {'border-bottom-style' : 'solid'}, + 'border-left-width': {'border-left-style' : 'solid'}, + 'top': {'position': 'absolute'}, + 'right': {'position': 'absolute'}, + 'bottom': {'position': 'absolute'}, + 'left': {'position': 'absolute'}, + 'z-index': {'position': 'absolute'}, + 'outline-offset': {'outline-style': 'solid'}, + 'outline-width': {'outline-style': 'solid'}, + 'word-spacing': {'width': '100px', 'height': '100px'}, + // unspecified properties + 'column-rule-width': {'column-rule-style': 'solid'}, + 'position': {'width': '50px', 'height': '50px', top: '10px', left: '50px'} +}; + +/* + * additional styles required *on the parent* to actually render + * (different browsers expect different environment) + */ +var parent_styles = { + 'border-top-width': {'border-top-style' : 'solid'}, + 'border-right-width': {'border-right-style' : 'solid'}, + 'border-bottom-width': {'border-bottom-style' : 'solid'}, + 'border-left-width': {'border-left-style' : 'solid'}, + 'height': {'width': '100px', 'height': '100px'}, + 'min-height': {'width': '100px', 'height': '100px'}, + 'max-height': {'width': '100px', 'height': '100px'}, + 'width': {'width': '100px', 'height': '100px'}, + 'min-width': {'width': '100px', 'height': '100px'}, + 'max-width': {'width': '100px', 'height': '100px'}, + // unspecified properties + 'position': {'position': 'relative', 'width': '100px', 'height': '100px'}, + // inheritance tests + 'top': {'width': '100px', 'height': '100px', 'position': 'relative'}, + 'right': {'width': '100px', 'height': '100px', 'position': 'relative'}, + 'bottom': {'width': '100px', 'height': '100px', 'position': 'relative'}, + 'left': {'width': '100px', 'height': '100px', 'position': 'relative'} +}; + + +function assemble(props) { + var tests = []; + + // assemble tests + for (var property in props) { + props[property].forEach(function(type) { + var _values = values[type](property); + Object.keys(_values).forEach(function(unit) { + var data = { + name: property + ' ' + type + '(' + unit + ')', + property: property, + valueType : type, + unit : unit, + parentStyle: extend({}, parent_styles[property] || {}), + from: extend({}, additional_styles[property] || {}), + to: {} + }; + + data.from[property] = _values[unit][0]; + data.to[property] = _values[unit][1]; + data.flags = _values[unit][2] || {}; + + tests.push(data); + }); + }); + } + + return tests; +} + +root.getPropertyTests = function() { + return assemble(properties); +}; + +root.getMissingPropertyTests = function() { + return assemble(missing_properties); +}; + +root.getUnspecifiedPropertyTests = function() { + return assemble(unspecified_properties); +}; + +root.getFontSizeRelativePropertyTests = function() { + var accepted = {}; + + for (var key in properties) { + if (!Object.prototype.hasOwnProperty.call(properties, key) || key === "font-size") { + continue; + } + + if (properties[key].indexOf('length') > -1) { + accepted[key] = ['length-em']; + } + } + + return assemble(accepted); +}; + +root.getAutoPropertyTests = function() { + var accepted = {}; + + for (var i = 0, key; key = properties_auto[i]; i++) { + accepted[key] = ['auto']; + } + + return assemble(accepted); +}; + +root.filterPropertyTests = function(tests, names) { + var allowed = {}; + var accepted = []; + + if (typeof names === "string") { + names = [names]; + } + + if (!(names instanceof RegExp)) { + names.forEach(function(name) { + allowed[name] = true; + }); + } + + tests.forEach(function(test) { + if (names instanceof RegExp) { + if (!test.name.match(names)) { + return; + } + } else if (!allowed[test.name]) { + return; + } + + accepted.push(test); + }); + + return accepted; +}; + +})(window);
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50%.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50%.png Binary files differnew file mode 100644 index 00000000000..cf2eea6b438 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50%.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50px.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50px.png Binary files differnew file mode 100644 index 00000000000..9f46583665c --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-h-50px.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-100px.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-100px.png Binary files differnew file mode 100644 index 00000000000..a837eca2225 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-100px.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-50px.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-50px.png Binary files differnew file mode 100644 index 00000000000..84141028020 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/ruler-v-50px.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/runParallelAsyncHarness.js b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/runParallelAsyncHarness.js new file mode 100644 index 00000000000..460f467930e --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/runParallelAsyncHarness.js @@ -0,0 +1,145 @@ +(function(root){ +'use strict'; +// testharness doesn't know about async test queues, +// so this wrapper takes care of that + +/* USAGE: + runParallelAsyncHarness({ + // list of data to test, must be array of objects. + // each object must contain a "name" property to describe the test + // besides name, the object can contain whatever data you need + tests: [ + {name: "name of test 1", custom: "data"}, + {name: "name of test 2", custom: "data"}, + // ... + ], + + // number of tests (tests, not test-cases!) to run concurrently + testsPerSlice: 100, + + // time in milliseconds a test-run takes + duration: 1000, + + // test-cases to run for for the test - there must be at least one + // each case creates its separate async_test() instance + cases: { + // test case named "test1" + test1: { + // run as a async_test.step() this callback contains your primary assertions + start: function(testCaseKey, data, options){}, + // run as a async_test.step() this callback contains assertions to be run + // when the test ended, immediately before teardown + done: function(testCaseKey, data, options){} + }, + // ... + } + + // all callbacks are optional: + + // invoked for individual test before it starts so you can setup the environment + // like DOM, CSS, adding event listeners and such + setup: function(data, options){}, + + // invoked after a test ended, so you can clean up the environment + // like DOM, CSS, removing event listeners and such + teardown: function(data, options){}, + + // invoked before a batch of tests ("slice") are run concurrently + // tests is an array of test data objects + sliceStart: function(options, tests) + + // invoked after a batch of tests ("slice") were run concurrently + // tests is an array of test data objects + sliceDone: function(options, tests) + + // invoked once all tests are done + done: function(options){} + }) +*/ +root.runParallelAsyncHarness = function(options) { + if (!options.cases) { + throw new Error("Options don't contain test cases!"); + } + + var noop = function(){}; + + // add a 100ms buffer to the test timeout, just in case + var duration = Math.ceil(options.duration + 100); + + // names of individual tests + var cases = Object.keys(options.cases); + + // run tests in a batch of slices + // primarily not to overload weak devices (tablets, phones, …) + // with too many tests running simultaneously + var iteration = -1; + var testPerSlice = options.testsPerSlice || 100; + var slices = Math.ceil(options.tests.length / testPerSlice); + + // initialize all async test cases + // Note: satisfying testharness.js needs to know all async tests before load-event + options.tests.forEach(function(data, index) { + data.cases = {}; + cases.forEach(function(name) { + data.cases[name] = async_test(data.name + " / " + name, {timeout: options.timeout || 60000}); + }); + }); + + function runLoop() { + iteration++; + if (iteration >= slices) { + // no more slice, we're done + (options.done || noop)(options); + return; + } + + // grab a slice of testss and initialize them + var offset = iteration * testPerSlice; + var tests = options.tests.slice(offset, offset + testPerSlice); + tests.forEach(function(data) { + (options.setup || noop)(data, options); + + }); + + // kick off the current slice of tests + (options.sliceStart || noop)(options, tests); + + // perform individual "start" test-case + tests.forEach(function(data) { + cases.forEach(function(name) { + data.cases[name].step(function() { + (options.cases[name].start || noop)(data.cases[name], data, options); + }); + }); + }); + + // conclude test (possibly abort) + setTimeout(function() { + tests.forEach(function(data) { + // perform individual "done" test-case + cases.forEach(function(name) { + data.cases[name].step(function() { + (options.cases[name].done || noop)(data.cases[name], data, options); + }); + }); + // clean up after individual test + (options.teardown || noop)(data, options); + // tell harness we're done with individual test-cases + cases.forEach(function(name) { + data.cases[name].done(); + }); + }); + + // finish the test for current slice of tests + (options.sliceDone || noop)(options, tests); + + // next test please, give the browser 50ms to do catch its breath + setTimeout(runLoop, 50); + }, duration); + } + + // allow DOMContentLoaded before actually doing something + setTimeout(runLoop, 100); +}; + +})(window);
\ No newline at end of file diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-purple.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-purple.png Binary files differnew file mode 100644 index 00000000000..0f522d78728 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-purple.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-teal.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-teal.png Binary files differnew file mode 100644 index 00000000000..e567f51b91b --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-teal.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-white.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-white.png Binary files differnew file mode 100644 index 00000000000..5853cbb238c --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/square-white.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-blue.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-blue.png Binary files differnew file mode 100644 index 00000000000..bf2759634d4 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-blue.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-green.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-green.png Binary files differnew file mode 100644 index 00000000000..0aa79b0c86b --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-green.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-lime.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-lime.png Binary files differnew file mode 100644 index 00000000000..55fd7fdaedf --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-lime.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-orange.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-orange.png Binary files differnew file mode 100644 index 00000000000..d3cd498b52b --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-orange.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-red.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-red.png Binary files differnew file mode 100644 index 00000000000..1caf25c992a --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-red.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-teal.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-teal.png Binary files differnew file mode 100644 index 00000000000..0293ce89dea --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-teal.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-white.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-white.png Binary files differnew file mode 100644 index 00000000000..1a7d4323d77 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-white.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-yellow.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-yellow.png Binary files differnew file mode 100644 index 00000000000..1591aa0e2e2 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/swatch-yellow.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-bl.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-bl.png Binary files differnew file mode 100644 index 00000000000..904e24e996a --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-bl.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-br.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-br.png Binary files differnew file mode 100644 index 00000000000..f413ff5c1a0 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-br.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-inner-half-size.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-inner-half-size.png Binary files differnew file mode 100644 index 00000000000..e473bf80efc --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-inner-half-size.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-outer.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-outer.png Binary files differnew file mode 100644 index 00000000000..82eeace7fc0 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-outer.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tl.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tl.png Binary files differnew file mode 100644 index 00000000000..f6ac0ef7e8f --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tl.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tr.png b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tr.png Binary files differnew file mode 100644 index 00000000000..59843ae54b6 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/test-tr.png diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/two.gif b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/two.gif Binary files differnew file mode 100644 index 00000000000..01435c80209 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/two.gif diff --git a/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/vendorPrefix.js b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/vendorPrefix.js new file mode 100644 index 00000000000..6cf3c5a3783 --- /dev/null +++ b/tests/wpt/css-tests/css-transitions-1_dev/xhtml1/reference/support/vendorPrefix.js @@ -0,0 +1,86 @@ +// +// Vendor-Prefix Helper Functions For Testing CSS +// + +(function(root) { +'use strict'; + +var prefixCache = {}; + +// convert "foo-bar" to "fooBar" +function camelCase(str) { + return str.replace(/\-(\w)/g, function(match, letter){ + return letter.toUpperCase(); + }); +} + +// vendor-prefix a css property +root.addVendorPrefix = function (name) { + var prefix = getVendorPrefix(name); + if (prefix === false) { + // property unknown to browser + return name; + } + + return prefix + name; +}; + +// vendor-prefix a css property value +root.addValueVendorPrefix = function (property, value) { + var prefix = getValueVendorPrefix(property, value); + if (prefix === false) { + // property unknown to browser + return name; + } + + return prefix + value; +}; + +// identify vendor-prefix for css property +root.getVendorPrefix = function(name) { + if (prefixCache[name] !== undefined) { + return prefixCache[name]; + } + + var elem = document.createElement("div"); + name = camelCase(name); + + if (name in elem.style) { + return prefixCache[name] = ""; + } + + var prefixes = ["Webkit", "Moz", "O", "ms"]; + var styles = ["-webkit-", "-moz-", "-o-", "-ms-"]; + var _name = name.substring(0, 1).toUpperCase() + name.substring(1); + + for (var i = 0, length = prefixes.length; i < length; i++) { + if (prefixes[i] + _name in elem.style) { + return prefixCache[name] = styles[i]; + } + } + + return prefixCache[name] = name in elem.style ? "" : false; +}; + +// identify vendor-prefix for css property value +root.getValueVendorPrefix = function(property, value) { + var elem = document.createElement("div"); + // note: webkit needs the element to be attached to the dom + document.body.appendChild(elem); + var styles = ["-webkit-", "-moz-", "-o-", "-ms-", ""]; + var _property = getVendorPrefix(property) + property; + for (var i=0, length = styles.length; i < length; i++) { + var _value = styles[i] + value; + elem.setAttribute('style', _property + ": " + _value); + var _computed = computedStyle(elem, _property); + if (_computed && _computed !== 'none') { + document.body.removeChild(elem); + return styles[i]; + } + } + document.body.removeChild(elem); + return false; +}; + + +})(window);
\ No newline at end of file |