Closed
Bug 484396
Opened 16 years ago
Closed 14 years ago
XMLHttpRequest.open throws exception on empty string url parameter
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: lists.bugzilla, Assigned: ttaubert)
References
()
Details
(Keywords: testcase, Whiteboard: [good first bug])
Attachments
(1 file, 5 obsolete files)
2.86 KB,
patch
|
bzbarsky
:
approval2.0+
|
Details | Diff | Splinter Review |
User-Agent: Opera/9.61 (Windows NT 5.1; U; en) Presto/2.1.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7
The following code alerts the fail message. Latest version of Opera and Chrome alert the success message, and will re-fetch the document if xhr.send() is called. According to the latest XHR draft spec, the empty URL value should be allowed and resolved against the document's base URI.
<!DOCTYPE html>
<html><body><script type="text/javascript">
var xhr = new XMLHttpRequest();
try {
xhr.open( 'GET', '' );
alert( 'open succeeded' );
} catch (e) {
alert( 'open failed: ' + e );
}
</script></body></html>
Reproducible: Always
Steps to Reproduce:
1. Save the code snippet provided into a HTML file.
2. Load the HTML file in Firefox.
3. Check the message in the alert dialog box.
Actual Results:
The alert dialog box says:
open failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest open]" nsresult: "0x8007057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://example.com/xhr.html :: <TOP_LEVEL> :: line 7" data: no]
Expected Results:
The alert dialog box should say:
open succeeded
Comment 1•16 years ago
|
||
Comment 2•16 years ago
|
||
I can reproduce with trunk.
Component: General → DOM
Keywords: testcase
OS: Windows XP → All
Product: Firefox → Core
QA Contact: general → general
Hardware: x86 → All
Version: unspecified → Trunk
Comment 3•14 years ago
|
||
Confirmed.
Status: UNCONFIRMED → NEW
Component: DOM → DOM: Mozilla Extensions
Ever confirmed: true
Comment 4•14 years ago
|
||
This probably is as easy as removing
NS_ENSURE_ARG(!url.IsEmpty());
from nsXMLHttpRequest::OpenRequest.
Whiteboard: [good first bug]
Assignee | ||
Comment 5•14 years ago
|
||
Updated•14 years ago
|
Attachment #499494 -
Flags: review?(Olli.Pettay)
Assignee | ||
Comment 6•14 years ago
|
||
Attachment #499494 -
Attachment is obsolete: true
Attachment #499764 -
Flags: review?(Olli.Pettay)
Attachment #499494 -
Flags: review?(Olli.Pettay)
Comment 7•14 years ago
|
||
Could you please add some test which checks that XHR with empty url actually
works.
I mean some test which checks that after xhr.send() when load event has been
dispatched, .responseText and/or .responseXML contain some valid value.
Assignee | ||
Comment 8•14 years ago
|
||
My first version already contained all the tests and I removed them because I tought they were too much... :)
Attachment #499764 -
Attachment is obsolete: true
Attachment #499809 -
Flags: review?(Olli.Pettay)
Attachment #499764 -
Flags: review?(Olli.Pettay)
Comment 9•14 years ago
|
||
Comment on attachment 499809 [details] [diff] [review]
v3, testing xhr.open(), xhr.send() and xhr.responseText
>diff --git a/content/base/test/test_bug484396.html b/content/base/test/test_bug484396.html
>new file mode 100644
>--- /dev/null
>+++ b/content/base/test/test_bug484396.html
>@@ -0,0 +1,49 @@
>+<!DOCTYPE HTML>
>+<html>
>+<!--
>+https://bugzilla.mozilla.org/show_bug.cgi?id=484396
>+-->
>+<head>
>+ <title>Test for Bug 484396</title>
>+ <script type="application/javascript" src="/MochiKit/packed.js"></script>
>+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
>+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
>+</head>
>+<body>
>+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484396">Mozilla Bug 484396</a>
>+<p id="display"></p>
>+<div id="content" style="display: none">
>+
>+</div>
>+<pre id="test">
>+<script type="application/javascript;version=1.8">
>+SimpleTest.waitForExplicitFinish();
>+
>+let msg = 'xhr.open() succeeds with empty url';
>+let xhr = new XMLHttpRequest();
Please use 'var' so that the testcase could run also in browsers which don't support 'let'.
Attachment #499809 -
Flags: review?(Olli.Pettay) → review+
Assignee | ||
Comment 10•14 years ago
|
||
I knew the first patch would not be that 'easy' :) Thanks for your review.
Attachment #499809 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Attachment #499810 -
Flags: review+
Attachment #499810 -
Flags: approval2.0?
Comment 11•14 years ago
|
||
Comment on attachment 499810 [details] [diff] [review]
v4, replaced let with var
Thanks for your patch, Tim! I'd like to note that, when carrying forward review, it's preferred not to set r+ yourself, though.
Attachment #499810 -
Flags: review+
Updated•14 years ago
|
Assignee: nobody → tim.taubert
Assignee | ||
Updated•14 years ago
|
Attachment #499810 -
Flags: approval2.0?
Assignee | ||
Comment 12•14 years ago
|
||
Pushed patch v5 to try today. Passed.
Attachment #368633 -
Attachment is obsolete: true
Attachment #499810 -
Attachment is obsolete: true
Attachment #501387 -
Flags: approval2.0?
Comment 14•14 years ago
|
||
Comment on attachment 501387 [details] [diff] [review]
patch v5 (updated to work with trunk again)
a=me
Tim, do you need this checked in, or can you land it?
Attachment #501387 -
Flags: approval2.0? → approval2.0+
Comment 15•14 years ago
|
||
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Updated•12 years ago
|
Component: DOM: Mozilla Extensions → DOM
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•