Revision be26c4f22f52f4c488d8e9d586db50eea2428a10 authored by Jim Evans on 15 March 2018, 21:21:56 UTC, committed by Jim Evans on 15 March 2018, 21:21:56 UTC
For the domain attribute of a returned cookie, if the attribute value
conatains a domain with a single dot ('.'), some user agents prepend a
leading dot onto the beginning of the attribute value. This is consistent
with RFC 2965. Some user agents expressly omit the leading dot, which is
consistent with the later RFC 6265. This commit allows both values as the
returned value of the domain attribute.
1 parent 750cfaf
Raw File
opaque-origin.https.html
<!DOCTYPE html>
<meta charset=utf-8>
<title>StorageManager API and opaque origins</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

function load_iframe(src, sandbox) {
  return new Promise(resolve => {
    const iframe = document.createElement('iframe');
    iframe.onload = () => { resolve(iframe); };
    if (sandbox)
      iframe.sandbox = sandbox;
    iframe.srcdoc = src;
    iframe.style.display = 'none';
    document.documentElement.appendChild(iframe);
  });
}

function wait_for_message(iframe) {
  return new Promise(resolve => {
    self.addEventListener('message', function listener(e) {
      if (e.source === iframe.contentWindow) {
        resolve(e.data);
        self.removeEventListener('message', listener);
      }
    });
  });
}

function make_script(snippet) {
  return '<script>' +
         '  window.onmessage = () => {' +
         '    try {' +
         '      (' + snippet + ')' +
         '        .then(' +
         '          result => {' +
         '            window.parent.postMessage({result: "no rejection"}, "*");' +
         '          }, ' +
         '          error => {' +
         '            window.parent.postMessage({result: error.name}, "*");' +
         '          });' +
         '    } catch (ex) {' +
         // Report if not implemented/exposed, rather than time out.
         '      window.parent.postMessage({result: ex.message}, "*");' +
         '    }' +
         '  };' +
         '<\/script>';
}

['navigator.storage.persist()',
 'navigator.storage.persisted()',
 'navigator.storage.estimate()'
].forEach(snippet => {
  promise_test(t => {
    return load_iframe(make_script(snippet))
      .then(iframe => {
        iframe.contentWindow.postMessage({}, '*');
        return wait_for_message(iframe);
      })
      .then(message => {
        assert_equals(message.result, 'no rejection',
                      `${snippet} should not reject`);
      });
  }, `${snippet} in non-sandboxed iframe should not reject`);

  promise_test(t => {
    return load_iframe(make_script(snippet), 'allow-scripts')
      .then(iframe => {
        iframe.contentWindow.postMessage({}, '*');
        return wait_for_message(iframe);
      })
      .then(message => {
        assert_equals(message.result, 'TypeError',
                      `${snippet} should reject with TypeError`);
      });
  }, `${snippet} in sandboxed iframe should reject with TypeError`);
});
</script>
back to top