==========
Fixed Bugs
==========

This file includes tests for bugs that were found and then fixed that don't fit
into the more documentation-centric sections above.


Unicode URLs
============

Unicode URLs or headers cause the entire constructed request to be unicode, and
(as of Python 2.4.4) Cookie.SimpleCookie checks the type of the input against
type(""), so it handles the value inappropriately, causing exceptions that
ended with::

      File "/home/benji/Python-2.4.4/lib/python2.4/Cookie.py", line 623, in load
        self.update(rawdata)
    ValueError: dictionary update sequence element #0 has length 1; 2 is required

As a work-around, unicode strings passed to Browser.open() are now converted to
ASCII before being passed on, as well as the key and value passed to
Browser.addHeader().

The tests below failed before the change was put in place.

    >>> from zope.testbrowser.testing import Browser
    >>> browser = Browser()
    >>> browser.addHeader('Cookie', 'test')
    >>> browser.open(u'http://localhost/@@/testbrowser/simple.html')

    >>> from zope.testbrowser.testing import Browser
    >>> browser = Browser()
    >>> browser.addHeader(u'Cookie', 'test')
    >>> browser.open('http://localhost/@@/testbrowser/simple.html')


Spaces in URL
=============

When URLs have spaces in them, they're handled correctly (before the bug was
fixed, you'd get "ValueError: too many values to unpack"):

    >>> browser.open('http://localhost/@@/testbrowser/navigate.html')
    >>> browser.getLink('Spaces in the URL').click()


.goBack() Truncation
====================

The .goBack() method used to truncate the .contents.

    >>> browser.open('http://localhost/@@/testbrowser/navigate.html')
    >>> actual_length = len(browser.contents)

    >>> browser.open('http://localhost/@@/testbrowser/navigate.html')
    >>> browser.open('http://localhost/@@/testbrowser/simple.html')
    >>> browser.goBack()
    >>> len(browser.contents) == actual_length
    True


Labeled Radio Buttons
=====================

The .getControl() method was sometimes unable to find radio buttons by label.

    >>> import ClientForm
    >>> # ClientForm._show_debug_messages()
    >>> browser.open('http://localhost/@@/testbrowser/radio.html')
    >>> browser.getControl('One').optionValue
    '1'
    >>> browser.getControl('Two').optionValue
    '2'
    >>> browser.getControl('Three').optionValue
    '3'


Fragment URLs
=============

Earlier versions of mechanize used to incorrectly follow links containing
fragments. We upgraded our dependency to a newer version of mechanize and make
sure this regression doesn't come back:

    >>> import ClientForm
    >>> browser.open('http://localhost/@@/testbrowser/fragment.html#asdf')
    >>> browser.url
    'http://localhost/@@/testbrowser/fragment.html#asdf'
    >>> browser.getLink('Follow me')
    <Link text='Follow me' url='http://localhost/@@/testbrowser/fragment.html#foo'>
    >>> browser.getLink('Follow me').click()


Textareas with HTML/XML
======================

    >>> browser.open('http://localhost/@@/testbrowser/textarea.html')
    >>> browser.getControl('Text Area').value
    '<block>\r\n  <feed/>\r\n    &\r\n</block>'
