| <!DOCTYPE html> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="timeout" content="long"/> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/get-host-info.sub.js"></script> |
| <script src="/common/utils.js"></script> |
| <script src="./resources/compression-dictionary-util.sub.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| [ |
| "dcb", |
| "dcz", |
| ].forEach(format => { |
| [ |
| {subframe_dictionary: "subframe-001.html", subframe_compressed: `self-compressed-subframe-001.html.${format}`}, |
| {subframe_dictionary: "style-001.css", subframe_compressed: `subframe-001-compressed-by-style-001.html.${format}`}, |
| {subframe_dictionary: "script-001.js", subframe_compressed: `subframe-001-compressed-by-script-001.html.${format}`}, |
| ].forEach(config => { |
| compression_dictionary_promise_test(async t => { |
| const test_id = token(); |
| // Load the non-compressed style to register it as a dictionary for itself. |
| await fetchStaticResourceWithUseAsDictionaryHeader(`${config.subframe_dictionary}?id=${test_id}`, `${config.subframe_compressed}?id=${test_id}`, "iframe"); |
| |
| // Wait for another dictionary to register to give a chance for the |
| // previous registration to complete. See comment in the 001 file about |
| // why we can't use waitUntilPreviousRequestHeaders, checkHeaders or checkHeader. |
| await registerAltDictionaryAndWait(t, `alt_${token()}`); |
| |
| // Append the compressed subframe. |
| const iframe = document.createElement("iframe"); |
| iframe.src = `./resources/static/${config.subframe_compressed}?id=${test_id}`; |
| const waitMessageFromIframe = new Promise(resolve => { |
| function iframeListener(event) { resolve(event.data === "ready"); } |
| window.addEventListener("message", iframeListener, {once: true}); |
| t.add_cleanup(_ => { |
| iframe.remove(); |
| window.removeEventListener("message", iframeListener); |
| }); |
| }); |
| await new Promise((resolve, reject) => { |
| iframe.onload = resolve; |
| iframe.onerror = _ => reject("load failed"); |
| document.body.appendChild(iframe); |
| }); |
| |
| // Verify script in HTML page was executed. |
| assert_true(await waitMessageFromIframe, "iframe posted its ready message"); |
| }, `Loading ${config.subframe_compressed} using ${config.subframe_dictionary} as a dictionary works`); |
| }); |
| }); |
| </script> |
| </body> |