XMLHttpRequest should support attribute responseURL as per latest XHR spec.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Oct 2014 17:16:44 +0000 (17:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Oct 2014 17:16:44 +0000 (17:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136938

Patch by Shivakumar JM <shiva.jm@samsung.com> on 2014-10-22
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Tests: http/tests/xmlhttprequest/basic-auth-responseURL.html
       http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html
       http/tests/xmlhttprequest/redirect-credentials-responseURL.html
       http/tests/xmlhttprequest/xmlhttprequest-responseURL.html

XMLHttpRequest should support attribute responseURL

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseURL):
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequest.idl:

LayoutTests:

Added test to check responseURL attribute in XMLHttpRequest.

* http/tests/xmlhttprequest/basic-auth-responseURL-expected.txt: Added.
* http/tests/xmlhttprequest/basic-auth-responseURL.html: Added.
* http/tests/xmlhttprequest/cross-origin-redirect-responseURL-expected.txt: Added.
* http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html: Added.
* http/tests/xmlhttprequest/redirect-credentials-responseURL-expected.txt: Added.
* http/tests/xmlhttprequest/redirect-credentials-responseURL.html: Added.
* http/tests/xmlhttprequest/xmlhttprequest-responseURL-expected.txt: Added.
* http/tests/xmlhttprequest/xmlhttprequest-responseURL.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175053 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h
Source/WebCore/xml/XMLHttpRequest.idl

index 79deea7..36b356e 100644 (file)
@@ -1,3 +1,21 @@
+2014-10-22  Shivakumar JM  <shiva.jm@samsung.com>
+
+        XMLHttpRequest should support attribute responseURL as per latest XHR spec.
+        https://bugs.webkit.org/show_bug.cgi?id=136938
+
+        Reviewed by Alexey Proskuryakov.
+
+        Added test to check responseURL attribute in XMLHttpRequest.
+
+        * http/tests/xmlhttprequest/basic-auth-responseURL-expected.txt: Added.
+        * http/tests/xmlhttprequest/basic-auth-responseURL.html: Added.
+        * http/tests/xmlhttprequest/cross-origin-redirect-responseURL-expected.txt: Added.
+        * http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html: Added.
+        * http/tests/xmlhttprequest/redirect-credentials-responseURL-expected.txt: Added.
+        * http/tests/xmlhttprequest/redirect-credentials-responseURL.html: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-responseURL-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-responseURL.html: Added.
+
 2014-10-22  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GStreamer] Do not use CachedResourceLoader, SecurityOrigin, ResourceBuffer and other WebCore types
diff --git a/LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL-expected.txt b/LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL-expected.txt
new file mode 100644 (file)
index 0000000..5b99f08
--- /dev/null
@@ -0,0 +1,18 @@
+Test XMLHttpRequest responseURL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+req.readyState = 0: responseURL = 
+PASS req.responseURL is ""
+req.readyState = 1: responseURL = 
+PASS req.responseURL is ""
+req.readyState = 1: responseURL = 
+PASS req.responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth/basic-auth.php?uid=async
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth/basic-auth.php?uid=async
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth/basic-auth.php?uid=async
+PASS req.responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth/basic-auth.php?uid=async"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL.html b/LayoutTests/http/tests/xmlhttprequest/basic-auth-responseURL.html
new file mode 100644 (file)
index 0000000..9d5e85e
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/javascript">
+description("Test XMLHttpRequest responseURL.");
+window.jsTestIsAsync = true;
+    
+//async
+req = new XMLHttpRequest;
+debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+shouldBeEqualToString('req.responseURL', '');
+req.open("GET", "resources/basic-auth/basic-auth.php?uid=async", true, "async", "123");
+debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+shouldBeEqualToString('req.responseURL', '');
+req.onreadystatechange = processStateChange;
+req.send("");
+debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+shouldBeEqualToString('req.responseURL', '');
+
+function processStateChange() {
+    debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+
+    if (req.readyState == 4) {
+        shouldBeEqualToString('req.responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth/basic-auth.php?uid=async');
+        finishJSTest();
+    }
+}
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL-expected.txt b/LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL-expected.txt
new file mode 100644 (file)
index 0000000..d6841de
--- /dev/null
@@ -0,0 +1,49 @@
+Test XMLHttpRequest responseURL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:7/
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:7/
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:7/
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:7/"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:22/
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:22/
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:22/
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:22/"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect-cors.php
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/redirect-cors.php
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/redirect-cors.php"
+req.readyState = 1: responseURL = 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html b/LayoutTests/http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html
new file mode 100644 (file)
index 0000000..beee7f9
--- /dev/null
@@ -0,0 +1,63 @@
+<html>
+<head></head>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+
+description('Test XMLHttpRequest responseURL.');
+
+window.jsTestIsAsync = true;
+
+function runTest(url, type) {
+    return new Promise(function(resolve, reject) {
+        var req = new XMLHttpRequest();
+        window.responseURL = req.responseURL;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        shouldBeEqualToString('responseURL', '');
+
+        req.open('GET', url);
+        req.responseType = type;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+
+        req.onreadystatechange = function() {
+            debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+            if (req.readyState == req.DONE)
+                resolve(req);
+        }      
+
+        req.send();
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+    });
+}
+
+runTest('resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi', 'text').then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow.cgi');
+
+    return runTest('resources/redirect.php?url=http://localhost:7/', 'document');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:7/');
+
+    return runTest('resources/redirect.php?url=http://localhost:22/', 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/redirect.php?url=http://localhost:22/');
+
+    return runTest('resources/redirect-cors.php', 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/redirect-cors.php');
+
+    req.open('GET', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
+}).catch(function(reason) {
+    testFailed(String(reason));
+}).then(finishJSTest, finishJSTest);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL-expected.txt b/LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL-expected.txt
new file mode 100644 (file)
index 0000000..f4ed952
--- /dev/null
@@ -0,0 +1,30 @@
+Test XMLHttpRequest responseURL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php"
+req.readyState = 1: responseURL = 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL.html b/LayoutTests/http/tests/xmlhttprequest/redirect-credentials-responseURL.html
new file mode 100644 (file)
index 0000000..92ecc46
--- /dev/null
@@ -0,0 +1,53 @@
+<html>
+<head></head>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+
+description('Test XMLHttpRequest responseURL.');
+
+window.jsTestIsAsync = true;
+
+function runTest(url, type, async, user, pwd) {
+    return new Promise(function(resolve, reject) {
+        var req = new XMLHttpRequest();
+        window.responseURL = req.responseURL;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        shouldBeEqualToString('responseURL', '');
+
+        req.open('GET', url, async, user, pwd);
+        req.responseType = type;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+
+        req.onreadystatechange = function() {
+            debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+            if (req.readyState == req.DONE)
+                resolve(req);
+        }      
+
+        req.send();
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+    });
+}
+
+runTest('resources/basic-auth-default/dir1/basic-auth.php', true, "test", "test", 'text').then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir1/basic-auth.php');
+
+    return runTest('resources/basic-auth-default/dir2/basic-auth.php', true, 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/basic-auth-default/dir2/basic-auth.php');
+
+    req.open('GET', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
+}).catch(function(reason) {
+    testFailed(String(reason));
+}).then(finishJSTest, finishJSTest);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL-expected.txt b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL-expected.txt
new file mode 100644 (file)
index 0000000..0b3f147
--- /dev/null
@@ -0,0 +1,70 @@
+Test XMLHttpRequest responseURL.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/network-simulator.php?command=connect/
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/network-simulator.php?command=connect/
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/network-simulator.php?command=connect/
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/network-simulator.php?command=connect/"
+req.readyState = 0: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 1: responseURL = 
+PASS responseURL is ""
+req.readyState = 2: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/supported-xml-content-types.cgi?type=foo
+req.readyState = 3: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/supported-xml-content-types.cgi?type=foo
+req.readyState = 4: responseURL = http://127.0.0.1:8000/xmlhttprequest/resources/supported-xml-content-types.cgi?type=foo
+PASS responseURL is "http://127.0.0.1:8000/xmlhttprequest/resources/supported-xml-content-types.cgi?type=foo"
+req.readyState = 1: responseURL = 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL.html b/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-responseURL.html
new file mode 100644 (file)
index 0000000..dc7a1f6
--- /dev/null
@@ -0,0 +1,73 @@
+<html>
+<head></head>
+<body>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+
+description('Test XMLHttpRequest responseURL.');
+
+window.jsTestIsAsync = true;
+
+function runTest(url, type) {
+    return new Promise(function(resolve, reject) {
+        var req = new XMLHttpRequest();
+        window.responseURL = req.responseURL;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        shouldBeEqualToString('responseURL', '');
+
+        req.open('GET', url);
+        req.responseType = type;
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+
+        req.onreadystatechange = function() {
+            debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+            if (req.readyState == req.DONE)
+                resolve(req);
+        }      
+
+        req.send();
+        debug('req.readyState = ' + req.readyState + ': responseURL = ' + req.responseURL);
+        window.responseURL = req.responseURL;
+        shouldBeEqualToString('responseURL', '');
+    });
+}
+
+runTest('resources/reply.txt', 'text').then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/reply.txt');
+
+    return runTest('resources/redirect_methods.php?url=reply.xml', 'document');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/reply.xml');
+
+    return runTest('resources/redirect_methods.php?url=not-found.txt', 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
+
+    return runTest('resources/cross-site-progress-events.cgi', 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/cross-site-progress-events.cgi');
+
+    return runTest('resources/network-simulator.php?command=connect/', 'text');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/network-simulator.php?command=connect/');
+
+    return runTest("resources/supported-xml-content-types.cgi?type=foo#bar/baz+xml", 'xml');
+}).then(function(req) {
+    window.responseURL = req.responseURL;
+    shouldBeEqualToString('responseURL', 'http://127.0.0.1:8000/xmlhttprequest/resources/supported-xml-content-types.cgi?type=foo');
+
+    req.open('GET', 'http://127.0.0.1:8000/xmlhttprequest/resources/not-found.txt');
+}).catch(function(reason) {
+    testFailed(String(reason));
+}).then(finishJSTest, finishJSTest);
+
+</script>
+</body>
+</html>
index 4fd2e13..c6c4211 100644 (file)
@@ -1,3 +1,22 @@
+2014-10-22  Shivakumar JM  <shiva.jm@samsung.com>
+
+        XMLHttpRequest should support attribute responseURL as per latest XHR spec.
+        https://bugs.webkit.org/show_bug.cgi?id=136938
+
+        Reviewed by Alexey Proskuryakov.
+
+        Tests: http/tests/xmlhttprequest/basic-auth-responseURL.html
+               http/tests/xmlhttprequest/cross-origin-redirect-responseURL.html
+               http/tests/xmlhttprequest/redirect-credentials-responseURL.html
+               http/tests/xmlhttprequest/xmlhttprequest-responseURL.html
+
+        XMLHttpRequest should support attribute responseURL
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::responseURL):
+        * xml/XMLHttpRequest.h:
+        * xml/XMLHttpRequest.idl:
+
 2014-10-22  Chris Dumez  <cdumez@apple.com>
 
         Add initial support for generating the StyleBuilder from CSSPropertyNames.in
index 558fde1..bf86f03 100644 (file)
@@ -335,6 +335,14 @@ String XMLHttpRequest::responseType()
     return "";
 }
 
+String XMLHttpRequest::responseURL() const
+{
+    URL responseURL(m_response.url());
+    responseURL.removeFragmentIdentifier();
+
+    return responseURL.string();
+}
+
 void XMLHttpRequest::setLastSendLineAndColumnNumber(unsigned lineNumber, unsigned columnNumber)
 {
     m_lastSendLineNumber = lineNumber;
index c5e13de..7c4d514 100644 (file)
@@ -132,6 +132,8 @@ public:
     String responseType();
     ResponseTypeCode responseTypeCode() const { return m_responseTypeCode; }
 
+    String responseURL() const;
+
     // response attribute has custom getter.
     JSC::ArrayBuffer* responseArrayBuffer();
     JSC::ArrayBuffer* optionalResponseArrayBuffer() const { return m_responseArrayBuffer.get(); }
index 02ab313..3a0320a 100644 (file)
@@ -89,6 +89,7 @@ enum XMLHttpRequestResponseType {
 
     readonly attribute unsigned short status;
     readonly attribute DOMString statusText;
+    readonly attribute DOMString responseURL;
 
     // Extension
     [RaisesException] void overrideMimeType(DOMString override);