dictionary-compressed.tentative.https.html (5192B)
1 <!DOCTYPE html> 2 <head> 3 <meta charset="utf-8"> 4 <meta name="timeout" content="long"/> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/common/get-host-info.sub.js"></script> 8 <script src="./resources/compression-dictionary-util.sub.js"></script> 9 </head> 10 <body> 11 <script> 12 13 // This is a set of tests for the dictionary itself being compressed, both by 14 // non-dictionary content encodings and dictionary encodings. The encoding used 15 // for the dictionary itself is independent of the encoding used for the data 16 // so the test uses different encodings just to make sure that the dictionaries 17 // don't carry any encoding-specific dependencies. 18 19 compression_dictionary_promise_test(async (t) => { 20 const dictionaryUrl = 21 `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?content_encoding=gzip`; 22 const dict = await (await fetch(dictionaryUrl)).text(); 23 assert_equals(dict, kDefaultDictionaryContent); 24 const dictionary_hash = await waitUntilAvailableDictionaryHeader(t, {}); 25 assert_equals(dictionary_hash, kDefaultDictionaryHashBase64); 26 27 // Check if the data compressed using the dictionary can be decompressed. 28 const data_url = `${kCompressedDataPath}?content_encoding=dcb`; 29 const data = await (await fetch(data_url)).text(); 30 assert_equals(data, kExpectedCompressedData); 31 }, 'Decompresion using gzip-encoded dictionary works as expected'); 32 33 compression_dictionary_promise_test(async (t) => { 34 const dictionaryUrl = 35 `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?content_encoding=br`; 36 const dict = await (await fetch(dictionaryUrl)).text(); 37 assert_equals(dict, kDefaultDictionaryContent); 38 const dictionary_hash = await waitUntilAvailableDictionaryHeader(t, {}); 39 assert_equals(dictionary_hash, kDefaultDictionaryHashBase64); 40 41 // Check if the data compressed using the dictionary can be decompressed. 42 const data_url = `${kCompressedDataPath}?content_encoding=dcz`; 43 const data = await (await fetch(data_url)).text(); 44 assert_equals(data, kExpectedCompressedData); 45 }, 'Decompresion using Brotli-encoded dictionary works as expected'); 46 47 compression_dictionary_promise_test(async (t) => { 48 const dictionaryUrl = 49 `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?content_encoding=zstd`; 50 const dict = await (await fetch(dictionaryUrl)).text(); 51 assert_equals(dict, kDefaultDictionaryContent); 52 const dictionary_hash = await waitUntilAvailableDictionaryHeader(t, {}); 53 assert_equals(dictionary_hash, kDefaultDictionaryHashBase64); 54 55 // Check if the data compressed using Brotli with the dictionary can be 56 // decompressed (Zstandard decompression of the data is tested separately). 57 const data_url = `${kCompressedDataPath}?content_encoding=dcb`; 58 const data = await (await fetch(data_url)).text(); 59 assert_equals(data, kExpectedCompressedData); 60 }, 'Decompresion using Zstandard-encoded dictionary works as expected'); 61 62 compression_dictionary_promise_test(async (t) => { 63 const dictionaryUrl = `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?id=id1`; 64 const dict = await (await fetch(dictionaryUrl)).text(); 65 assert_equals(dict, kDefaultDictionaryContent); 66 assert_equals( 67 await waitUntilAvailableDictionaryHeader(t, {}), 68 kDefaultDictionaryHashBase64); 69 70 // Register another dictionary, compressed with dcb using the first dictionary. 71 const compressedDictionaryUrl = 72 `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?content_encoding=dcb&id=id2`; 73 const dict2 = await (await fetch(compressedDictionaryUrl)).text(); 74 assert_equals(dict2, kDefaultDictionaryContent); 75 await waitUntilHeader(t, "dictionary-id", {expected_header: '"id2"'}); 76 77 // Check if the data compressed using dcz with the updated dictionary works. 78 const data_url = `${SAME_ORIGIN_RESOURCES_URL}/compressed-data.py?content_encoding=dcz`; 79 const data = await (await fetch(data_url)).text(); 80 assert_equals(data, kExpectedCompressedData); 81 }, 'A dcb dictionary-compressed dictionary can be used as a dictionary for future requests.'); 82 83 compression_dictionary_promise_test(async (t) => { 84 const dictionaryUrl = `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?id=id1`; 85 const dict = await (await fetch(dictionaryUrl)).text(); 86 assert_equals(dict, kDefaultDictionaryContent); 87 assert_equals( 88 await waitUntilAvailableDictionaryHeader(t, {}), 89 kDefaultDictionaryHashBase64); 90 91 // Register another dictionary, compressed with dcz using the first dictionary. 92 const compressedDictionaryUrl = 93 `${SAME_ORIGIN_RESOURCES_URL}/register-dictionary.py?content_encoding=dcz&id=id2`; 94 const dict2 = await (await fetch(compressedDictionaryUrl)).text(); 95 assert_equals(dict2, kDefaultDictionaryContent); 96 await waitUntilHeader(t, "dictionary-id", {expected_header: '"id2"'}); 97 98 // Check if the data compressed using dcb with the updated dictionary works. 99 const data_url = `${SAME_ORIGIN_RESOURCES_URL}/compressed-data.py?content_encoding=dcb`; 100 const data = await (await fetch(data_url)).text(); 101 assert_equals(data, kExpectedCompressedData); 102 }, 'A dcz dictionary-compressed dictionary can be used as a dictionary for future requests.'); 103 104 </script> 105 </body>