11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<meta charset=windows-1252> 31cb0ef41Sopenharmony_ci<title>Character Decoding: UTF-32 (not supported) subresource of windows-1252 document</title> 41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 61cb0ef41Sopenharmony_ci<body> 71cb0ef41Sopenharmony_ci<script> 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Since UTF-32 is not supported: 101cb0ef41Sopenharmony_ci// * HTML resources will use the parent encoding (windows-1252) 111cb0ef41Sopenharmony_ci// * XML resources will default to UTF-8 121cb0ef41Sopenharmony_ci// ... except for the UTF-32LE-with-BOM case, where the UTF-32 131cb0ef41Sopenharmony_ci// BOM will be mistaken for a UTF-16LE BOM (FF FE 00 00), in which 141cb0ef41Sopenharmony_ci// case it will be interpreted as UTF-16LE. 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst samples = [ 171cb0ef41Sopenharmony_ci {file: 'resources/utf-32-big-endian-bom.html', 181cb0ef41Sopenharmony_ci characterSet: 'windows-1252', 191cb0ef41Sopenharmony_ci contentType: 'text/html' 201cb0ef41Sopenharmony_ci }, 211cb0ef41Sopenharmony_ci {file: 'resources/utf-32-big-endian-bom.xml', 221cb0ef41Sopenharmony_ci characterSet: 'UTF-8', 231cb0ef41Sopenharmony_ci contentType: 'application/xml' 241cb0ef41Sopenharmony_ci }, 251cb0ef41Sopenharmony_ci {file: 'resources/utf-32-big-endian-nobom.html', 261cb0ef41Sopenharmony_ci characterSet: 'windows-1252', 271cb0ef41Sopenharmony_ci contentType: 'text/html' 281cb0ef41Sopenharmony_ci }, 291cb0ef41Sopenharmony_ci {file: 'resources/utf-32-big-endian-nobom.xml', 301cb0ef41Sopenharmony_ci characterSet: 'UTF-8', 311cb0ef41Sopenharmony_ci contentType: 'application/xml' 321cb0ef41Sopenharmony_ci }, 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci {file: 'resources/utf-32-little-endian-bom.html', 351cb0ef41Sopenharmony_ci characterSet: 'UTF-16LE', 361cb0ef41Sopenharmony_ci contentType: 'text/html' 371cb0ef41Sopenharmony_ci }, 381cb0ef41Sopenharmony_ci {file: 'resources/utf-32-little-endian-bom.xml', 391cb0ef41Sopenharmony_ci characterSet: 'UTF-16LE', 401cb0ef41Sopenharmony_ci contentType: 'application/xml' 411cb0ef41Sopenharmony_ci }, 421cb0ef41Sopenharmony_ci {file: 'resources/utf-32-little-endian-nobom.html', 431cb0ef41Sopenharmony_ci characterSet: 'windows-1252', 441cb0ef41Sopenharmony_ci contentType: 'text/html' 451cb0ef41Sopenharmony_ci }, 461cb0ef41Sopenharmony_ci {file: 'resources/utf-32-little-endian-nobom.xml', 471cb0ef41Sopenharmony_ci characterSet: 'UTF-8', 481cb0ef41Sopenharmony_ci contentType: 'application/xml' 491cb0ef41Sopenharmony_ci } 501cb0ef41Sopenharmony_ci]; 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_cisamples.forEach(expected => async_test(t => { 531cb0ef41Sopenharmony_ci const iframe = document.createElement('iframe'); 541cb0ef41Sopenharmony_ci iframe.src = expected.file; 551cb0ef41Sopenharmony_ci iframe.onload = t.step_func_done(() => { 561cb0ef41Sopenharmony_ci const doc = iframe.contentDocument; 571cb0ef41Sopenharmony_ci assert_equals(doc.contentType, expected.contentType); 581cb0ef41Sopenharmony_ci assert_equals(doc.characterSet, expected.characterSet); 591cb0ef41Sopenharmony_ci // The following is a little quirky as non-well-formed XML isn't defined in sufficient detail to 601cb0ef41Sopenharmony_ci // be able to use more precise assertions. 611cb0ef41Sopenharmony_ci assert_true( 621cb0ef41Sopenharmony_ci !('dataset' in doc.documentElement) || 631cb0ef41Sopenharmony_ci doc.documentElement.dataset['parsed'] !== 'yes', 641cb0ef41Sopenharmony_ci 'Should not have parsed as (X)HTML'); 651cb0ef41Sopenharmony_ci }); 661cb0ef41Sopenharmony_ci document.body.appendChild(iframe); 671cb0ef41Sopenharmony_ci t.add_cleanup(() => iframe.remove()); 681cb0ef41Sopenharmony_ci}, `Expect ${expected.file} to parse as ${expected.characterSet}`)); 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci</script> 711cb0ef41Sopenharmony_ci</body> 72