Blame dom/base/test/test_bug704320_policyset.html

Packit f0b94e
Packit f0b94e
<html>
Packit f0b94e
Packit f0b94e
This checks if the right policies are applied from a given string (including whitespace, invalid policy strings, etc).  It doesn't do a complete check for all load types; that's done in another test.
Packit f0b94e
https://bugzilla.mozilla.org/show_bug.cgi?id=704320
Packit f0b94e
-->
Packit f0b94e
Packit f0b94e
<head>
Packit f0b94e
  <meta charset="utf-8">
Packit f0b94e
  <title>Test policies for Bug 704320</title>
Packit f0b94e
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
Packit f0b94e
  <script type="application/javascript" src="referrerHelper.js"></script>
Packit f0b94e
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
Packit f0b94e
Packit f0b94e
<script type="application/javascript">
Packit f0b94e
Packit f0b94e
SimpleTest.waitForExplicitFinish();
Packit f0b94e
var advance = function() { tests.next(); };
Packit f0b94e
Packit f0b94e
/**
Packit f0b94e
 * This is the main test routine -- serialized by use of a generator.
Packit f0b94e
 * It resets the counter, then performs two tests in sequence using
Packit f0b94e
 * the same iframe.
Packit f0b94e
 */
Packit f0b94e
var tests = (function*() {
Packit f0b94e
  var iframe = document.getElementById("testframe");
Packit f0b94e
  const sjs = "/tests/dom/base/test/bug704320.sjs?action=generate-policy-test";
Packit f0b94e
Packit f0b94e
Packit f0b94e
  // basic calibration check
Packit f0b94e
  // reset the counter
Packit f0b94e
  yield resetCounter();
Packit f0b94e
Packit f0b94e
  // load the first test frame
Packit f0b94e
  // it will call back into this function via postMessage when it finishes loading.
Packit f0b94e
  // and continue beyond the yield.
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('default');
Packit f0b94e
Packit f0b94e
  // check the first test (two images, no referrers)
Packit f0b94e
  yield checkIndividualResults("default", ["full"]);
Packit f0b94e
Packit f0b94e
  // check invalid policy
Packit f0b94e
  // According to the spec section Determine token's Policy,if there is a policy
Packit f0b94e
  // token and it is not one of the expected tokens, Empty string should be the
Packit f0b94e
  // policy used.
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('invalid-policy');
Packit f0b94e
  yield checkIndividualResults("invalid", ["full"]);
Packit f0b94e
Packit f0b94e
  // whitespace checks.
Packit f0b94e
  // according to the spec section 4.1, the content attribute's value
Packit f0b94e
  // is fed to the token policy algorithm after stripping leading and
Packit f0b94e
  // trailing whitespace.
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('default   ');
Packit f0b94e
  yield checkIndividualResults("trailing whitespace", ["full"]);
Packit f0b94e
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape(' origin\f');
Packit f0b94e
  yield checkIndividualResults("trailing form feed", ["origin"]);
Packit f0b94e
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('\f origin');
Packit f0b94e
  yield checkIndividualResults("leading form feed", ["origin"]);
Packit f0b94e
Packit f0b94e
  // origin when cross-origin (trimming whitespace)
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape(' origin-when-cross-origin');
Packit f0b94e
  yield checkIndividualResults("origin-when-cross-origin", ["origin", "full"]);
Packit f0b94e
Packit f0b94e
  // according to the spec section 4.1:
Packit f0b94e
  // "If the meta element lacks a content attribute, or if that attribute’s
Packit f0b94e
  //  value is the empty string, then abort these steps."
Packit f0b94e
  // This means empty or missing content attribute means to ignore the meta
Packit f0b94e
  // tag and use default policy.
Packit f0b94e
  // Whitespace here is space, tab, LF, FF and CR.
Packit f0b94e
  // http://www.w3.org/html/wg/drafts/html/CR/infrastructure.html#space-character
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape(' \t  ');
Packit f0b94e
  yield checkIndividualResults("basic whitespace only policy", ["full"]);
Packit f0b94e
Packit f0b94e
  // and double-check that no-referrer works.
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('no-referrer');
Packit f0b94e
  yield checkIndividualResults("no-referrer", ["none"]);
Packit f0b94e
Packit f0b94e
  // Case insensitive
Packit f0b94e
  yield resetCounter();
Packit f0b94e
  yield iframe.src = sjs + "&policy=" + escape('\f OrigIn');
Packit f0b94e
  yield checkIndividualResults("origin case insensitive", ["origin"]);
Packit f0b94e
Packit f0b94e
  // complete.
Packit f0b94e
  SimpleTest.finish();
Packit f0b94e
})();
Packit f0b94e
Packit f0b94e
</script>
Packit f0b94e
</head>
Packit f0b94e
Packit f0b94e
<body onload="tests.next();">
Packit f0b94e
  <iframe id="testframe"></iframe>
Packit f0b94e
Packit f0b94e
</body>
Packit f0b94e
</html>
Packit f0b94e