Fix Busted Functional Tests
Fix the functional tests busted by Revision 212. Sync with latest HTML5lib.
This commit is contained in:
parent
51474e06c8
commit
5db9ddaf47
12 changed files with 67 additions and 30 deletions
|
@ -13,6 +13,11 @@ class AdminControllerTest < Test::Unit::TestCase
|
|||
@controller = AdminController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
class << @request.session
|
||||
attr_accessor :dbman
|
||||
end
|
||||
# simulate a cookie session store
|
||||
@request.session.dbman = FakeSessionDbMan
|
||||
@wiki = Wiki.new
|
||||
@oak = pages(:oak)
|
||||
@elephant = pages(:elephant)
|
||||
|
|
|
@ -15,6 +15,11 @@ class FileControllerTest < Test::Unit::TestCase
|
|||
@controller = FileController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
class << @request.session
|
||||
attr_accessor :dbman
|
||||
end
|
||||
# simulate a cookie session store
|
||||
@request.session.dbman = FakeSessionDbMan
|
||||
@web = webs(:test_wiki)
|
||||
@wiki = Wiki.new
|
||||
WikiFile.delete_all
|
||||
|
|
|
@ -20,6 +20,11 @@ class WikiControllerTest < Test::Unit::TestCase
|
|||
@controller = WikiController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
class << @request.session
|
||||
attr_accessor :dbman
|
||||
end
|
||||
# simulate a cookie session store
|
||||
@request.session.dbman = FakeSessionDbMan
|
||||
@wiki = Wiki.new
|
||||
@web = webs(:test_wiki)
|
||||
@home = @page = pages(:home_page)
|
||||
|
|
|
@ -8,10 +8,16 @@ require 'application'
|
|||
require 'test/unit'
|
||||
require 'active_record/fixtures'
|
||||
require 'action_controller/test_process'
|
||||
#require 'action_web_service/test_invoke'
|
||||
#require 'breakpoint'
|
||||
require 'wiki_content'
|
||||
require 'url_generator'
|
||||
require 'digest/sha1'
|
||||
|
||||
# simulates cookie session store
|
||||
class FakeSessionDbMan
|
||||
def self.generate_digest(data)
|
||||
Digest::SHA1.hexdigest("secure")
|
||||
end
|
||||
end
|
||||
|
||||
Test::Unit::TestCase.pre_loaded_fixtures = false
|
||||
Test::Unit::TestCase.use_transactional_fixtures = true
|
||||
|
|
|
@ -281,7 +281,11 @@ module HTML5
|
|||
@tell += 1 if @buffer[@tell] == "\n"
|
||||
c = "\n"
|
||||
when "\x80" .. "\x9F"
|
||||
c = ''.force_encoding('UTF-8') << ENTITIES_WINDOWS1252[c.ord-0x80]
|
||||
c = ENTITIES_WINDOWS1252[c.ord-0x80].chr('utf-8')
|
||||
when "\xA0" .. "\xFF"
|
||||
if c.encoding == Encoding::ASCII_8BIT
|
||||
c = c.encode('utf-8','iso-8859-1')
|
||||
end
|
||||
end
|
||||
|
||||
if c == "\x0D"
|
||||
|
@ -299,8 +303,7 @@ module HTML5
|
|||
@col += 1
|
||||
end
|
||||
|
||||
# binary utf-8
|
||||
c.ord > 126 ? [c.ord].pack('U') : c
|
||||
c
|
||||
|
||||
when 0x01..0x7F
|
||||
if c == 0x0D
|
||||
|
|
10
vendor/plugins/HTML5lib/lib/html5/sniffer.rb
vendored
10
vendor/plugins/HTML5lib/lib/html5/sniffer.rb
vendored
|
@ -7,9 +7,9 @@ module Sniffer
|
|||
|
||||
while pos < s.length
|
||||
case s[pos]
|
||||
when 0x09, 0x20, 0x0A, 0x0D # tab, space, LF, CR
|
||||
when ?\t, ?\ , ?\n, ?\r # 0x09, 0x20, 0x0A, 0x0D == tab, space, LF, CR
|
||||
pos += 1
|
||||
when 0x3C # "<"
|
||||
when ?< # 0x3C
|
||||
pos += 1
|
||||
if s[pos..pos+2] == "!--" # [0x21, 0x2D, 0x2D]
|
||||
pos += 3
|
||||
|
@ -17,13 +17,13 @@ module Sniffer
|
|||
pos += 1
|
||||
end
|
||||
pos += 3
|
||||
elsif s[pos] == 0x21 # "!"
|
||||
elsif s[pos] == ?! # 0x21
|
||||
pos += 1
|
||||
until s[pos] == 0x3E or pos >= s.length # ">"
|
||||
until s[pos] == ?> or pos >= s.length # 0x3E
|
||||
pos += 1
|
||||
end
|
||||
pos += 1
|
||||
elsif s[pos] == 0x3F # "?"
|
||||
elsif s[pos] == ?? # 0x3F
|
||||
until s[pos..pos+1] == "?>" or pos >= s.length # [0x3F, 0x3E]
|
||||
pos += 1
|
||||
end
|
||||
|
|
|
@ -118,7 +118,11 @@ module HTML5
|
|||
end
|
||||
|
||||
if 0 < charAsInt and charAsInt <= 1114111 and not (55296 <= charAsInt and charAsInt <= 57343)
|
||||
char = [charAsInt].pack('U')
|
||||
if String.method_defined? :force_encoding
|
||||
char = charAsInt.chr('utf-8')
|
||||
else
|
||||
char = [charAsInt].pack('U')
|
||||
end
|
||||
else
|
||||
char = [0xFFFD].pack('U')
|
||||
@token_queue << {:type => :ParseError, :data => "cant-convert-numeric-entity", :datavars => {"charAsInt" => charAsInt}}
|
||||
|
|
6
vendor/plugins/HTML5lib/test/test_lxp.rb
vendored
6
vendor/plugins/HTML5lib/test/test_lxp.rb
vendored
|
@ -9,7 +9,11 @@ def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser)
|
|||
document = parser.parse(input.chomp, :lowercase_attr_name => false, :lowercase_element_name => false).root
|
||||
if not expected
|
||||
expected = input.chomp.gsub(XMLELEM,&sortattrs)
|
||||
expected = expected.gsub(/&#(\d+);/) {[$1.to_i].pack('U')}
|
||||
if expected.respond_to? :force_encoding
|
||||
expected = expected.gsub(/&#(\d+);/) {$1.to_i.chr('utf-8')}
|
||||
else
|
||||
expected = expected.gsub(/&#(\d+);/) {[$1.to_i].pack('U')}
|
||||
end
|
||||
output = document.to_s.gsub(/'/,'"').gsub(XMLELEM,&sortattrs)
|
||||
assert_equal(expected, output)
|
||||
else
|
||||
|
|
|
@ -12,11 +12,11 @@ class SanitizeTest < Test::Unit::TestCase
|
|||
include HTML5
|
||||
|
||||
def sanitize_xhtml stream
|
||||
XHTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s
|
||||
XHTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).join
|
||||
end
|
||||
|
||||
def sanitize_html stream
|
||||
HTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s
|
||||
HTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).join
|
||||
end
|
||||
|
||||
def sanitize_rexml stream
|
||||
|
|
|
@ -50,7 +50,7 @@ class Html5SerializeTestcase < Test::Unit::TestCase
|
|||
flunk("Expected: #{expected.inspect}, Received: #{result.inspect}")
|
||||
end
|
||||
|
||||
return if test_name == 'optionaltags'
|
||||
next if test_name == 'optionaltags'
|
||||
|
||||
result = HTML5::XHTMLSerializer.
|
||||
serialize(JsonWalker.new(test["input"]), (test["options"] || {}))
|
||||
|
@ -60,7 +60,6 @@ class Html5SerializeTestcase < Test::Unit::TestCase
|
|||
elsif !expected.include?(result)
|
||||
flunk("Expected: #{expected.inspect}, Received: #{result.inspect}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
22
vendor/plugins/HTML5lib/test/test_stream.rb
vendored
22
vendor/plugins/HTML5lib/test/test_stream.rb
vendored
|
@ -5,6 +5,14 @@ require 'html5/inputstream'
|
|||
class HTMLInputStreamTest < Test::Unit::TestCase
|
||||
include HTML5
|
||||
|
||||
def getc stream
|
||||
if String.method_defined? :force_encoding
|
||||
stream.char.force_encoding('binary')
|
||||
else
|
||||
stream.char
|
||||
end
|
||||
end
|
||||
|
||||
def test_char_ascii
|
||||
stream = HTMLInputStream.new("'", :encoding=>'ascii')
|
||||
assert_equal('ascii', stream.char_encoding)
|
||||
|
@ -13,23 +21,23 @@ class HTMLInputStreamTest < Test::Unit::TestCase
|
|||
|
||||
def test_char_null
|
||||
stream = HTMLInputStream.new("\x00")
|
||||
assert_equal("\xef\xbf\xbd", stream.char)
|
||||
assert_equal("\xef\xbf\xbd", getc(stream))
|
||||
end
|
||||
|
||||
def test_char_utf8
|
||||
stream = HTMLInputStream.new("\xe2\x80\x98", :encoding=>'utf-8')
|
||||
assert_equal('utf-8', stream.char_encoding)
|
||||
assert_equal("\xe2\x80\x98", stream.char)
|
||||
assert_equal("\xe2\x80\x98", getc(stream))
|
||||
end
|
||||
|
||||
def test_char_win1252
|
||||
stream = HTMLInputStream.new("\xa2\xc5\xf1\x92\x86")
|
||||
assert_equal('windows-1252', stream.char_encoding)
|
||||
assert_equal("\xc2\xa2", stream.char)
|
||||
assert_equal("\xc3\x85", stream.char)
|
||||
assert_equal("\xc3\xb1", stream.char)
|
||||
assert_equal("\xe2\x80\x99", stream.char)
|
||||
assert_equal("\xe2\x80\xa0", stream.char)
|
||||
assert_equal("\xc2\xa2", getc(stream))
|
||||
assert_equal("\xc3\x85", getc(stream))
|
||||
assert_equal("\xc3\xb1", getc(stream))
|
||||
assert_equal("\xe2\x80\x99", getc(stream))
|
||||
assert_equal("\xe2\x80\xa0", getc(stream))
|
||||
end
|
||||
|
||||
def test_bom
|
||||
|
|
10
vendor/plugins/HTML5lib/test19.rb
vendored
10
vendor/plugins/HTML5lib/test19.rb
vendored
|
@ -13,20 +13,18 @@ require 'test/test_cli'
|
|||
|
||||
require 'test/test_input_stream'
|
||||
|
||||
# incompatible encoding regexp match
|
||||
# require 'test/test_lxp'
|
||||
require 'test/test_lxp'
|
||||
|
||||
require 'test/test_parser'
|
||||
|
||||
# warning: method redefined; discarding old test
|
||||
# warning: instance variable @expanded_name not initialized
|
||||
# SimpleDelegator.class
|
||||
# require 'test/test_sanitizer'
|
||||
|
||||
# warning: instance variable @delegate_sd_obj not initialized
|
||||
# require 'test/test_serializer'
|
||||
require 'test/test_serializer'
|
||||
|
||||
# undebugged
|
||||
# require 'test/test_sniffer'
|
||||
require 'test/test_sniffer'
|
||||
|
||||
require 'test/test_stream'
|
||||
|
||||
|
|
Loading…
Reference in a new issue