<!DOCTYPE html>
<meta charset="utf-8">
<title>embed and object are not intercepted</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/test-helpers.sub.js?pipe=sub"></script>
<body>
<script>
let registration;

const kScript = 'resources/embed-and-object-are-not-intercepted-worker.js';
const kScope = 'resources/';

promise_test(t => {
    return service_worker_unregister_and_register(t, kScript, kScope)
      .then(registration => {
          promise_test(() => {
              return registration.unregister();
            }, 'restore global state');

          return wait_for_state(t, registration.installing, 'activated');
        })
  }, 'initialize global state');

promise_test(t => {
    let frame;
    return with_iframe('resources/embed-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request for embedded content was not intercepted');
        });
  }, 'requests for EMBED elements of embedded HTML content should not be intercepted by service workers');

promise_test(t => {
    let frame;
    return with_iframe('resources/object-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request for embedded content was not intercepted');
        });
  }, 'requests for OBJECT elements of embedded HTML content should not be intercepted by service workers');

promise_test(t => {
    let frame;
    return with_iframe('resources/embed-image-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request was not intercepted');
        });
  }, 'requests for EMBED elements of an image should not be intercepted by service workers');

promise_test(t => {
    let frame;
    return with_iframe('resources/object-image-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request was not intercepted');
        });
  }, 'requests for OBJECT elements of an image should not be intercepted by service workers');

promise_test(t => {
    let frame;
    return with_iframe('resources/object-navigation-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request for embedded content was not intercepted');
        });
  }, 'post-load navigation of OBJECT elements should not be intercepted by service workers');


promise_test(t => {
    let frame;
    return with_iframe('resources/embed-navigation-is-not-intercepted-iframe.html')
      .then(f => {
          frame = f;
          t.add_cleanup(() => { frame.remove(); });
          return frame.contentWindow.test_promise;
        })
      .then(result => {
          assert_equals(result, 'request for embedded content was not intercepted');
        });
  }, 'post-load navigation of EMBED elements should not be intercepted by service workers');
</script>
