Bug 959190 - [URL API] stringify href attribute, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 13 Jan 2014 23:46:04 +0100
changeset 163226 e2f3827a2f441cd3509b86c6546fd7617b0a5764
parent 163225 481e4766030eefc867a29701d37007c3796e696b
child 163227 0928cbf5f9a41d0269160fa6c6df2241e84f6378
push id25986
push userkwierso@gmail.com
push dateTue, 14 Jan 2014 04:44:33 +0000
treeherdermozilla-central@b114534a9386 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs959190
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 959190 - [URL API] stringify href attribute, r=bz
dom/base/URL.h
dom/base/test/mochitest.ini
dom/base/test/test_url.html
dom/base/test/test_urlutils_stringify.html
dom/webidl/HTMLAnchorElement.webidl
dom/webidl/HTMLAreaElement.webidl
dom/webidl/URLUtils.webidl
dom/workers/URL.h
dom/workers/test/urlApi_worker.js
--- a/dom/base/URL.h
+++ b/dom/base/URL.h
@@ -113,16 +113,21 @@ public:
   URLSearchParams* GetSearchParams();
 
   void SetSearchParams(URLSearchParams* aSearchParams);
 
   void GetHash(nsString& aRetval) const;
 
   void SetHash(const nsAString& aArg);
 
+  void Stringify(nsString& aRetval) const
+  {
+    GetHref(aRetval);
+  }
+
   // URLSearchParamsObserver
   void URLSearchParamsUpdated() MOZ_OVERRIDE;
   void URLSearchParamsNeedsUpdates() MOZ_OVERRIDE;
 
 private:
   nsIURI* GetURI() const
   {
     return mURI;
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -23,28 +23,29 @@ support-files =
 [test_history_state_null.html]
 [test_innersize_scrollport.html]
 [test_messageChannel.html]
 [test_messageChannel_cloning.html]
 [test_messageChannel_pingpong.html]
 [test_messageChannel_post.html]
 [test_messageChannel_pref.html]
 [test_messageChannel_start.html]
+[test_messagemanager_targetchain.html]
 [test_messageChannel_transferable.html]
 [test_messageChannel_unshipped.html]
 [test_named_frames.html]
 [test_nondomexception.html]
+[test_openDialogChromeOnly.html]
+[test_postMessage_solidus.html]
 [test_screen_orientation.html]
 [test_settimeout_inner.html]
 [test_setting_opener.html]
 [test_url.html]
+[test_url_empty_port.html]
+[test_urlExceptions.html]
+[test_urlSearchParams.html]
+[test_urlutils_stringify.html]
 [test_window_constructor.html]
 [test_window_cross_origin_props.html]
 [test_window_enumeration.html]
 [test_window_extensible.html]
 [test_window_indexing.html]
 [test_writable-replaceable.html]
-[test_urlExceptions.html]
-[test_openDialogChromeOnly.html]
-[test_messagemanager_targetchain.html]
-[test_url_empty_port.html]
-[test_postMessage_solidus.html]
-[test_urlSearchParams.html]
--- a/dom/base/test/test_url.html
+++ b/dom/base/test/test_url.html
@@ -265,13 +265,15 @@ https://bugzilla.mozilla.org/show_bug.cg
     if ('username' in test) is(url.username, test.username, "username");
     if ('password' in test) is(url.password, test.password, "password");
     if ('host' in test) is(url.host, test.host, "host");
     if ('hostname' in test) is(test.hostname, url.hostname, "hostname");
     if ('port' in test) is(test.port, url.port, "port");
     if ('pathname' in test) is(test.pathname, url.pathname, "pathname");
     if ('search' in test) is(test.search, url.search, "search");
     if ('hash' in test) is(test.hash, url.hash, "hash");
+
+    if ('href' in test) is (test.href, url + '', 'stringify works');
   }
 
   </script>
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_urlutils_stringify.html
@@ -0,0 +1,38 @@
+
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=959190
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 959190</title>
+  <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=959190">Mozilla Bug 959190</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  <iframe name="x" id="x"></iframe>
+  <iframe name="y" id="y"></iframe>
+</div>
+<pre id="test">
+</pre>
+  <a id="link" href="http://www.example.com:8080">foobar</a>
+  <area id="area" href="http://www.example.com:8080" />
+  <script type="application/javascript">
+
+  var url = new URL('http://www.example.com:8080');
+  is(url + '', 'http://www.example.com:8080/', 'URL stringify');
+
+  var link = document.getElementById("link");
+  is(link + '', 'http://www.example.com:8080/', 'Anchor stringify');
+
+  var area = document.getElementById("area");
+  is(area + '', 'http://www.example.com:8080/', 'Area stringify');
+
+  is((location + '').indexOf('http://mochi.test:8888/tests/dom/base/test/test_urlutils_stringify.html'), 0, 'Location stringify');
+  </script>
+</body>
+</html>
--- a/dom/webidl/HTMLAnchorElement.webidl
+++ b/dom/webidl/HTMLAnchorElement.webidl
@@ -8,17 +8,16 @@
  * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
 // http://www.whatwg.org/specs/web-apps/current-work/#the-a-element
 interface HTMLAnchorElement : HTMLElement {
-  stringifier;
            [SetterThrows]
            attribute DOMString target;
            [SetterThrows]
            attribute DOMString download;
            [SetterThrows]
            attribute DOMString ping;
            [SetterThrows]
            attribute DOMString rel;
--- a/dom/webidl/HTMLAreaElement.webidl
+++ b/dom/webidl/HTMLAreaElement.webidl
@@ -9,17 +9,16 @@
  &
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
 // http://www.whatwg.org/specs/web-apps/current-work/#the-area-element
 interface HTMLAreaElement : HTMLElement {
-stringifier;
            [SetterThrows]
            attribute DOMString alt;
            [SetterThrows]
            attribute DOMString coords;
            [SetterThrows]
            attribute DOMString shape;
            [SetterThrows]
            attribute DOMString target;
--- a/dom/webidl/URLUtils.webidl
+++ b/dom/webidl/URLUtils.webidl
@@ -24,10 +24,13 @@ interface URLUtils {
            attribute DOMString password;
            attribute DOMString host;
            attribute DOMString hostname;
            attribute DOMString port;
            attribute DOMString pathname;
            attribute DOMString search;
            attribute URLSearchParams? searchParams;
            attribute DOMString hash;
+
+  // Bug 824857 should remove this.
+  stringifier;
 };
 
--- a/dom/workers/URL.h
+++ b/dom/workers/URL.h
@@ -107,16 +107,21 @@ public:
   URLSearchParams* GetSearchParams();
 
   void SetSearchParams(URLSearchParams* aSearchParams);
 
   void GetHash(nsString& aHost) const;
 
   void SetHash(const nsAString& aHash);
 
+  void Stringify(nsString& aRetval) const
+  {
+    GetHref(aRetval);
+  }
+
   // IURLSearchParamsObserver
   void URLSearchParamsUpdated() MOZ_OVERRIDE;
   void URLSearchParamsNeedsUpdates() MOZ_OVERRIDE;
 
 private:
   URLProxy* GetURLProxy() const
   {
     return mURLProxy;
--- a/dom/workers/test/urlApi_worker.js
+++ b/dom/workers/test/urlApi_worker.js
@@ -258,13 +258,15 @@ onmessage = function() {
     if ('username' in test) is(url.username, test.username, "username");
     if ('password' in test) is(url.password, test.password, "password");
     if ('host' in test) is(url.host, test.host, "host");
     if ('hostname' in test) is(test.hostname, url.hostname, "hostname");
     if ('port' in test) is(test.port, url.port, "port");
     if ('pathname' in test) is(test.pathname, url.pathname, "pathname");
     if ('search' in test) is(test.search, url.search, "search");
     if ('hash' in test) is(test.hash, url.hash, "hash");
+
+    if ('href' in test) is (test.href, url + '', 'stringify works');
   }
 
   postMessage({type: 'finish' });
 }