From 32ef1d3d0bcfe7ed8778656e2e09836eecdba5e5 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Mon, 20 Jul 2015 08:40:04 -0700 Subject: [PATCH] Bug 1175736 - Add iframe referrer attribute tests. r=ckerschb, r=baku --- dom/base/test/mochitest.ini | 3 + dom/base/test/referrer_testserver.sjs | 56 ++++++++++++++- dom/base/test/test_iframe_referrer.html | 55 +++++++++++++++ .../test/test_iframe_referrer_changing.html | 50 +++++++++++++ .../test/test_iframe_referrer_invalid.html | 70 +++++++++++++++++++ 5 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 dom/base/test/test_iframe_referrer.html create mode 100644 dom/base/test/test_iframe_referrer_changing.html create mode 100644 dom/base/test/test_iframe_referrer_invalid.html diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index 4f8dfffc097..7db79375d3a 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -678,6 +678,9 @@ support-files = referrerHelper.js [test_anchor_area_referrer_changing.html] [test_anchor_area_referrer_invalid.html] [test_anchor_area_referrer_rel.html] +[test_iframe_referrer.html] +[test_iframe_referrer_changing.html] +[test_iframe_referrer_invalid.html] [test_caretPositionFromPoint.html] [test_classList.html] # This test fails on the Mac for some reason diff --git a/dom/base/test/referrer_testserver.sjs b/dom/base/test/referrer_testserver.sjs index 679fcac0a19..4e47174d177 100644 --- a/dom/base/test/referrer_testserver.sjs +++ b/dom/base/test/referrer_testserver.sjs @@ -15,6 +15,40 @@ function createTestUrl(aPolicy, aAction, aName, aType) { 'type=' + aType; } +// test page using iframe referrer attribute +function createIframeTestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aChangingMethod) { + var metaString = ""; + if (aMetaPolicy) { + metaString = ''; + } + var changeString = ''; + if (aChangingMethod === 'setAttribute') { + changeString = `document.getElementById("myframe").setAttribute("referrer", "${aNewAttributePolicy}")`; + } else if (aChangingMethod === 'property') { + changeString = `document.getElementById("myframe").referrer = "${aNewAttributePolicy}"`; + } + var iFrameString = ``; + + return ` + + + ${metaString} + + + ${iFrameString} + + + `; +} + function buildAnchorString(aMetaPolicy, aReferrerPolicy, aName, aRelString){ if (aReferrerPolicy) { return `${aReferrerPolicy}`; @@ -123,7 +157,10 @@ function handleRequest(request, response) { setSharedState(SHARED_KEY, JSON.stringify(result)); - if (type === "link") { + if (type === "iframe") { + // return iframe page + response.write("I am the iframe"); + } else if (type === "link") { // forward link click to redirect URL to finish test var loc = "http://" + BASE_URL + "?ACTION=redirect"; response.setStatusLine('1.1', 302, 'Found'); @@ -170,6 +207,23 @@ function handleRequest(request, response) { return; } + // iframe + _getPage = createIframeTestPageUsingRefferer.bind(null, metaPolicy, attributePolicy, newAttributePolicy, name); + + // aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aChangingMethod + if (action === 'generate-iframe-policy-test') { + response.write(_getPage()); + return; + } + if (action === 'generate-iframe-changing-policy-test-set-attribute') { + response.write(_getPage('setAttribute')); + return; + } + if (action === 'generate-iframe-changing-policy-test-property') { + response.write(_getPage('property')); + return; + } + response.write("I don't know action " + action); return; } diff --git a/dom/base/test/test_iframe_referrer.html b/dom/base/test/test_iframe_referrer.html new file mode 100644 index 00000000000..ddbe590399e --- /dev/null +++ b/dom/base/test/test_iframe_referrer.html @@ -0,0 +1,55 @@ + + + + + Test iframe referrer policy attribute for Bug 1175736 + + + + + + + + + + + + diff --git a/dom/base/test/test_iframe_referrer_changing.html b/dom/base/test/test_iframe_referrer_changing.html new file mode 100644 index 00000000000..43e096cd420 --- /dev/null +++ b/dom/base/test/test_iframe_referrer_changing.html @@ -0,0 +1,50 @@ + + + + + Test iframe referrer policy attribute for Bug 1175736 + + + + + + + + + + + + diff --git a/dom/base/test/test_iframe_referrer_invalid.html b/dom/base/test/test_iframe_referrer_invalid.html new file mode 100644 index 00000000000..03abfc5c153 --- /dev/null +++ b/dom/base/test/test_iframe_referrer_invalid.html @@ -0,0 +1,70 @@ + + + + + Test iframe referrer policy attribute for Bug 1175736 + + + + + + + + + + + +