Bug 1149913 - Disable bug 1093611. Set pref dom.url.encode_decode_hash to true. r=honzab, a=sledru
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 21 Apr 2015 15:30:41 +0300
changeset 260228 a9be9167d92b
parent 260227 0b3c5b65610e
child 260229 0920ace0d8b0
push id723
push userryanvm@gmail.com
push date2015-04-22 14:15 +0000
treeherdermozilla-release@22f8fa3a9273 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab, sledru
bugs1149913, 1093611
milestone38.0
Bug 1149913 - Disable bug 1093611. Set pref dom.url.encode_decode_hash to true. r=honzab, a=sledru
dom/base/test/test_url.html
dom/html/test/test_hash_encoded.html
dom/workers/test/urlApi_worker.js
modules/libpref/init/all.js
testing/web-platform/meta/url/a-element.html.ini
testing/web-platform/meta/url/a-element.xhtml.ini
testing/web-platform/meta/workers/WorkerLocation_hash_encoding.htm.ini
--- a/dom/base/test/test_url.html
+++ b/dom/base/test/test_url.html
@@ -1,9 +1,8 @@
-
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test URL API</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
@@ -112,17 +111,17 @@
       port: '',
       pathname: '/',
       search: '?test',
       hash: ''
     },
     { url: 'http://example.com/carrot#question%3f',
       base: undefined,
       error: false,
-      hash: '#question%3f'
+      hash: '#question?'
     },
     { url: 'https://example.com:4443?',
       base: undefined,
       error: false,
       protocol: 'https:',
       port: '4443',
       pathname: '/',
       hash: '',
--- a/dom/html/test/test_hash_encoded.html
+++ b/dom/html/test/test_hash_encoded.html
@@ -2,24 +2,52 @@
 <html>
 <head>
 <title>Test link.hash attribute</title>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
-<a id="target1" href="http://www.example.com/#q=♥â¥#hello"></a>
-<a id="target2" href="http://www.example.com/#q=%E2%99%A5%C3%A2%C2%A5"></a>
-<a id="target3" href="http://www.example.com/#/search/%23important"></a>
-<a id="target4" href='http://www.example.com/#{"a":[13, 42], "b":{"key":"value"}}'></a>
-
 <pre id="test">
 
 <script>
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({"set": [['dom.url.encode_decode_hash', false]]}, runTest);
+
+function runTest() {
+  setupTest();
+  doTestEncoded();
+  SimpleTest.finish();
+}
+
+function setupTest() {
+  var target1 = document.createElement("a");
+  target1.id =  "target1";
+  target1.href = "http://www.example.com/#q=♥â¥#hello";
+  document.body.appendChild(target1);
+
+  var target2 = document.createElement("a");
+  target2.id =  "target2";
+  target2.href = "http://www.example.com/#q=%E2%99%A5%C3%A2%C2%A5";
+  document.body.appendChild(target2);
+
+  var target3 = document.createElement("a");
+  target3.id =  "target3";
+  target3.href = "http://www.example.com/#/search/%23important";
+  document.body.appendChild(target3);
+
+  var target4 = document.createElement("a");
+  target4.id =  "target4";
+  target4.href = 'http://www.example.com/#{"a":[13, 42], "b":{"key":"value"}}';
+  document.body.appendChild(target4);
+}
+
+function doTestEncoded() {
   // Tests Link::GetHash
 
   // Check that characters aren't being encoded
   var target = document.getElementById("target1");
   is(target.hash, '#q=♥â¥#hello', 'Unexpected link hash');
 
   // Check that encoded characters aren't being decoded
   target = document.getElementById("target2");
@@ -27,19 +55,17 @@
 
   // A more regular use case
   target = document.getElementById("target3");
   is(target.hash, '#/search/%23important', 'Unexpected link hash');
 
   // Some JSON
   target = document.getElementById("target4");
   is(target.hash, '#{"a":[13, 42], "b":{"key":"value"}}', 'Unexpected link hash');
-</script>
 
-<script>
   // Tests URL::GetHash
 
   var url = new URL("http://www.example.com/#q=♥â¥#hello")
   is(url.hash, '#q=♥â¥#hello', 'Unexpected url hash');
 
   url = new URL("http://www.example.com/#q=%E2%99%A5%C3%A2%C2%A5")
   is(url.hash, '#q=%E2%99%A5%C3%A2%C2%A5', 'Unexpected url hash');
 
@@ -63,29 +89,30 @@
   var parsed = JSON.parse(target.hash.substring(1));
   is(parsed.b.key, 'value', 'JSON not parsed correctly');
 
   url = new URL("http://www.example.com/test/");
   url.hash = '#{"a":[13, 42], "b":{"key":"value"}}';
   is(target.hash, '#{"a":[13, 42], "b":{"key":"value"}}', 'Unexpected url hash');
   parsed = JSON.parse(target.hash.substring(1));
   is(parsed.b.key, 'value', 'JSON not parsed correctly');
-</script>
 
-<script>
   // Tests nsLocation::GetHash
 
   window.history.pushState(1, document.title, '#q=♥â¥#hello');
   is(location.hash,'#q=♥â¥#hello', 'Unexpected location hash');
 
   window.history.pushState(1, document.title, '#q=%E2%99%A5%C3%A2%C2%A5');
   is(location.hash,'#q=%E2%99%A5%C3%A2%C2%A5', 'Unexpected location hash');
 
   window.history.pushState(1, document.title, '#/search/%23important');
   is(location.hash,'#/search/%23important', 'Unexpected location hash');
 
   window.history.pushState(1, document.title, '#{"a":[13, 42], "b":{"key":"value"}}');
   is(location.hash,'#{"a":[13, 42], "b":{"key":"value"}}', 'Unexpected location hash');
+
+}
+
 </script>
 
 </pre>
 </body>
 </html>
--- a/dom/workers/test/urlApi_worker.js
+++ b/dom/workers/test/urlApi_worker.js
@@ -106,17 +106,17 @@ onmessage = function() {
       port: '',
       pathname: '/',
       search: '?test',
       hash: ''
     },
     { url: 'http://example.com/carrot#question%3f',
       base: undefined,
       error: false,
-      hash: '#question%3f'
+      hash: '#question?'
     },
     { url: 'https://example.com:4443?',
       base: undefined,
       error: false,
       protocol: 'https:',
       port: '4443',
       pathname: '/',
       hash: '',
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -169,17 +169,17 @@ pref("dom.keyboardevent.dispatch_during_
 // Whether the WebCrypto API is enabled
 pref("dom.webcrypto.enabled", true);
 
 // Whether the UndoManager API is enabled
 pref("dom.undo_manager.enabled", false);
 
 // Whether URL,nsLocation,Link::GetHash should be percent encoded
 // in setter and percent decoded in getter (old behaviour = true)
-pref("dom.url.encode_decode_hash", false);
+pref("dom.url.encode_decode_hash", true);
 
 // Whether to run add-on code in different compartments from browser code. This
 // causes a separate compartment for each (addon, global) combination, which may
 // significantly increase the number of compartments in the system.
 #ifdef NIGHTLY_BUILD
 pref("dom.compartment_per_addon", true);
 #else
 pref("dom.compartment_per_addon", false);
--- a/testing/web-platform/meta/url/a-element.html.ini
+++ b/testing/web-platform/meta/url/a-element.html.ini
@@ -337,8 +337,22 @@
     expected: FAIL
 
   [Parsing: <x> against <test:test>]
     expected: FAIL
 
   [Parsing: <data:test# \xc2\xbb> against <about:blank>]
     expected: FAIL
 
+  [Parsing: <http://f:21/ b ? d # e > against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <#\xce\xb2> against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <http://www.google.com/foo?bar=baz# \xc2\xbb> against <about:blank>]
+    expected: FAIL
+
+  [Parsing: <#β> against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <http://www.google.com/foo?bar=baz# »> against <about:blank>]
+    expected: FAIL
--- a/testing/web-platform/meta/url/a-element.xhtml.ini
+++ b/testing/web-platform/meta/url/a-element.xhtml.ini
@@ -361,8 +361,22 @@
     expected: FAIL
 
   [Parsing: <x> against <test:test>]
     expected: FAIL
 
   [Parsing: <data:test# \xc2\xbb> against <about:blank>]
     expected: FAIL
 
+  [Parsing: <http://f:21/ b ? d # e > against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <#\xce\xb2> against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <http://www.google.com/foo?bar=baz# \xc2\xbb> against <about:blank>]
+    expected: FAIL
+
+  [Parsing: <#β> against <http://example.org/foo/bar>]
+    expected: FAIL
+
+  [Parsing: <http://www.google.com/foo?bar=baz# »> against <about:blank>]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/workers/WorkerLocation_hash_encoding.htm.ini
@@ -0,0 +1,4 @@
+[WorkerLocation_hash_encoding.htm]
+  type: testharness
+  [ WorkerLocation.hash with url encoding string ]
+    expected: FAIL