Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable passing flag to CSS validator regarding vendor extensions #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/w3c_validators/css_validator.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def set_language!(lang = 'en')
@options[:lang] = lang @options[:lang] = lang
end end


# whether to treat presence of CSS vendor extension as error or merely a warning
def set_vendor_extension_warning!(level = 'Default')
@options[:vextwarning] = nil if level.to_s.downcase == 'default'
@options[:vextwarning] = 'true' if level.to_s.downcase == 'warnings'
@options[:vextwarning] = 'false' if level.to_s.downcase == 'errors'
end

# Validate the CSS of an URI. # Validate the CSS of an URI.
# #
# Returns W3CValidators::Results. # Returns W3CValidators::Results.
Expand Down
15 changes: 13 additions & 2 deletions test/test_css_validator.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ def setup
sleep 1 sleep 1
end end


def test_vendor_extensions_as_errors
@v.set_vendor_extension_warning!('Errors')
r = @v.validate_text('some-class { -moz-border-radius: 3px; }')
assert_errors r, 1
end

def test_vendor_extensions_as_warnings
@v.set_vendor_extension_warning!('Warnings')
r = @v.validate_text('some-class { -moz-border-radius: 3px; }')
assert_no_errors r
assert_warnings r, 1
end

def test_overriding_css_profile def test_overriding_css_profile
@v.set_profile!(:svgbasic) @v.set_profile!(:svgbasic)
r = @v.validate_text(@invalid_fragment) r = @v.validate_text(@invalid_fragment)
Expand Down Expand Up @@ -46,6 +59,4 @@ def test_validating_text_via_file
assert_errors r, 1 assert_errors r, 1
end end




end end