Bug 1260664 - W3C Reflect referrerPolicy as a limited enumerated attribute. r=franziskuskiefer . r=smaug
authorThomas Nguyen <tnguyen@mozilla.com>
Mon, 18 Apr 2016 18:35:47 +0800
changeset 332314 643063a2427b3a6a5bf5b11fed0bf2830e6bae25
parent 332313 68442febc36c4f17cbaddca86994621b6ff28668
child 332315 1c638e1c121c51a803f3457e910cba1b021838b1
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfranziskuskiefer, smaug
bugs1260664
milestone48.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 1260664 - W3C Reflect referrerPolicy as a limited enumerated attribute. r=franziskuskiefer . r=smaug MozReview-Commit-ID: Dppj4iuZnFp
dom/html/HTMLAnchorElement.h
dom/html/HTMLAreaElement.h
dom/html/HTMLIFrameElement.h
dom/html/HTMLImageElement.h
dom/html/test/mochitest.ini
dom/html/test/test_bug1260664.html
testing/web-platform/tests/referrer-policy/generic/subresource-test/attr-referrer-invalid-value.html
--- a/dom/html/HTMLAnchorElement.h
+++ b/dom/html/HTMLAnchorElement.h
@@ -122,17 +122,17 @@ public:
     SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
   }
   void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
   {
     SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
   }
   void GetReferrerPolicy(nsAString& aReferrer)
   {
-    GetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer);
+    GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
   }
   nsDOMTokenList* RelList();
   void GetHreflang(DOMString& aValue)
   {
     GetHTMLAttr(nsGkAtoms::hreflang, aValue);
   }
   void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv)
   {
--- a/dom/html/HTMLAreaElement.h
+++ b/dom/html/HTMLAreaElement.h
@@ -126,17 +126,17 @@ public:
   nsDOMTokenList* RelList();
 
   void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
   {
     SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
   }
   void GetReferrerPolicy(nsAString& aReferrer)
   {
-    GetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer);
+    GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
   }
 
   // The Link::GetOrigin is OK for us
 
   // Link::Link::GetProtocol is OK for us
   // Link::Link::SetProtocol is OK for us
 
   // The Link::GetUsername is OK for us
--- a/dom/html/HTMLIFrameElement.h
+++ b/dom/html/HTMLIFrameElement.h
@@ -160,19 +160,18 @@ public:
     SetHTMLAttr(nsGkAtoms::marginheight, aMarginHeight, aError);
   }
   void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError);
   }
   void GetReferrerPolicy(nsAString& aReferrer)
   {
-    GetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer);
+    GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
   }
-
   nsIDocument* GetSVGDocument()
   {
     return GetContentDocument();
   }
   bool Mozbrowser() const
   {
     return GetBoolAttr(nsGkAtoms::mozbrowser);
   }
--- a/dom/html/HTMLImageElement.h
+++ b/dom/html/HTMLImageElement.h
@@ -192,17 +192,17 @@ public:
     SetHTMLAttr(nsGkAtoms::border, aBorder, aError);
   }
   void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError);
   }
   void GetReferrerPolicy(nsAString& aReferrer)
   {
-    GetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer);
+    GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
   }
 
   net::ReferrerPolicy
   GetImageReferrerPolicy() override
   {
     return GetReferrerPolicyAsEnum();
   }
 
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -602,9 +602,10 @@ skip-if = buildapp == 'b2g' # bug 112901
 [test_image_clone_load.html]
 [test_bug1203668.html]
 [test_bug1166138.html]
 [test_bug1230665.html]
 [test_filepicker_default_directory.html]
 skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
 [test_bug1233598.html]
 [test_bug1250401.html]
+[test_bug1260664.html]
 [test_allowMedia.html]
new file mode 100644
--- /dev/null
+++ b/dom/html/test/test_bug1260664.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1260664
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1260664</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="reflect.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=1260664">Mozilla Bug 1260664</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1260664 **/
+SpecialPowers.setBoolPref("network.http.enablePerElementReferrer", true);
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(runTests);
+
+function runTests() {
+  var elements = [ "iframe", "img", "a", "area" ];
+
+  for (var i = 0; i < elements.length; ++i) {
+    reflectLimitedEnumerated({
+      element: document.createElement(elements[i]),
+      attribute: { content: "referrerpolicy", idl: "referrerPolicy" },
+      validValues: [ "no-referrer",
+                     "origin",
+                     /** These 2 below values are still invalid, please see
+                       Bug 1178337 - Valid referrer attribute values **/
+                     /** "no-referrer-when-downgrade",
+                     "origin-when-cross-origin", **/
+                     "unsafe-url" ],
+      invalidValues: [
+        "", "  orIgin   ", "  unsafe-uRl  ", "  No-RefeRRer  ", " fOoBaR  "
+      ],
+      defaultValue: "",
+    });
+  }
+
+  SpecialPowers.clearUserPref("network.http.enablePerElementReferrer");
+  SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
--- a/testing/web-platform/tests/referrer-policy/generic/subresource-test/attr-referrer-invalid-value.html
+++ b/testing/web-platform/tests/referrer-policy/generic/subresource-test/attr-referrer-invalid-value.html
@@ -1,25 +1,25 @@
 <!DOCTYPE html>
 <html>
   <head>
-    <title>Invalid referrerpolicy attribute value</title>
+    <title>Invalid referrerPolicy attribute value</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
   </head>
   <body>
-    <h1>Invalid referrerpolicy attribute value</h1>
+    <h1>Invalid referrerPolicy attribute value</h1>
     <pre>Running...</pre>
 
     <script>
       test(function () {
           var elements = ["iframe", "img", "a", "area"];
           for (var i = 0; i < elements.length; i++) {
               var elem = document.createElement(elements[i]);
-              elem.referrerpolicy = "unsafe-url";
-              assert_equals(elem.referrerpolicy, "unsafe-url");
-              elem.referrerpolicy = "not-valid-value";
-              assert_equals(elem.referrerpolicy, "");
+              elem.referrerPolicy = "unsafe-url";
+              assert_equals(elem.referrerPolicy, "unsafe-url");
+              elem.referrerPolicy = "not-valid-value";
+              assert_equals(elem.referrerPolicy, "");
           }
       }, "Invalid referrerpolicy values not reflected");
     </script>
   </body>
 </html>