dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

rgba Color Values are incorrect #50

Open jheimbach opened 10 years ago

jheimbach commented 10 years ago

I have searched a lot for this issue, and i know that the Problem isn't dalekjs but maybe there is a solution for this.

Webdriver/the Browser gives 'wrong' rgba values.

For example if you write something like this. 'backgroundcolor is correct': function (test) { test.open(url) .assert.css('.backgroundStripe', 'background-color', 'rgba(98, 202, 217, 0.7)', 'backgroundStripe has right color') .done(); }

Instead of the expected (and in the stylesheet defined) value rgba(98, 202, 217, 0.7) phantomjs returns rgba(98, 202, 217, 0.699219) and chrome returns rgba(98, 202, 217, 0.701961)

I think the reason why this happend is: http://stackoverflow.com/a/13754993/3233058

Maybe there is a simple solution for this, but i haven't found one.

Versions i used:

asciidisco commented 10 years ago

I´ve seen this before but totally forgot about it. Indeed your findings seem to be the root of the issue. Maybe @rodneyrehm has heard about this before and can add something to the discussion?

rodneyrehm commented 10 years ago

While specifications CSS2 Color and CSS3 Color define the computed value to be formatted "as specified", no browser reliably does this at this point.

I'm not sure I like the notion of testing for a given color in the first place. I'd argue that you should be testing for an element being in a given state (certain class name present, data-attribute filled, etc). But if you must check for a specific style, you'll have to deal with the short comings of computedValue() yourself.

For colors I can recommend chromath for working with colors and this SO question might help with creating a fuzzy color compare function

Munter commented 10 years ago

I've had to deal with these comparisons myself in the color library I wrote because I use floating point representations internally. This is how I solved it: https://github.com/One-com/one-color#comparing-color-objects

MrOutput commented 8 years ago

my rgba values don't even work on phantom 3