Changeset 58064 in webkit


Ignore:
Timestamp:
Apr 21, 2010 11:49:50 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-04-21 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

URL LayoutTests don't run on Firefox
https://bugs.webkit.org/show_bug.cgi?id=37974

It turns out Firefox doesn't handle base URLs properly if we go through
the DOM to create the <base> and <a> elements. If we switch to
document.write, we can run the tests in Firefox (even though
document.write is lame).

  • fast/url/resources/utilities.js: (canonicalize): (setBaseURL):
Location:
trunk/LayoutTests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58058 r58064  
     12010-04-21  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        URL LayoutTests don't run on Firefox
     6        https://bugs.webkit.org/show_bug.cgi?id=37974
     7
     8        It turns out Firefox doesn't handle base URLs properly if we go through
     9        the DOM to create the <base> and <a> elements.  If we switch to
     10        document.write, we can run the tests in Firefox (even though
     11        document.write is lame).
     12
     13        * fast/url/resources/utilities.js:
     14        (canonicalize):
     15        (setBaseURL):
     16
    1172010-04-21  Ben Murdoch  <benm@google.com>
    218
  • trunk/LayoutTests/fast/url/resources/utilities.js

    r57635 r58064  
    11function canonicalize(url)
    22{
    3   var a = document.createElement("a");
    4   a.href = url;
    5   return a.href;
     3  // It would be more elegant to use the DOM here, but we use document.write()
     4  // so the tests run correctly in Firefox.
     5  var id = Math.random();
     6  document.write("<a id='" + id + "' href='" + url + "'></a>");
     7  return document.getElementById(id).href;
    68}
    79
    810function setBaseURL(url)
    911{
    10   var base = document.createElement("base");
    11   base.href = url;
    12   document.documentElement.appendChild(base);
     12  // According to the HTML5 spec, we're only supposed to honor <base> elements
     13  // in the <head>, but we use document.write() here to make the test run in
     14  // Firefox.
     15  document.write('<base href="' + url + '">');
    1316}
Note: See TracChangeset for help on using the changeset viewer.