| Joshua Bell | 315b16b | 2018-11-12 10:37:07 | [diff] [blame] | 1 | <!DOCTYPE html> | 
|  | 2 | <meta charset=windows-1252> | 
|  | 3 | <title>Character Decoding: UTF-32 (not supported) subresource of windows-1252 document</title> | 
|  | 4 | <script src="/resources/testharness.js"></script> | 
|  | 5 | <script src="/resources/testharnessreport.js"></script> | 
|  | 6 | <body> | 
|  | 7 | <script> | 
|  | 8 |  | 
|  | 9 | // Since UTF-32 is not supported: | 
|  | 10 | // * HTML resources will use the parent encoding (windows-1252) | 
|  | 11 | // * XML resources will default to UTF-8 | 
|  | 12 | // ... except for the UTF-32LE-with-BOM case, where the UTF-32 | 
|  | 13 | // BOM will be mistaken for a UTF-16LE BOM (FF FE 00 00), in which | 
|  | 14 | // case it will be interpreted as UTF-16LE. | 
|  | 15 |  | 
|  | 16 | const samples = [ | 
|  | 17 | {file: 'resources/utf-32-big-endian-bom.html', | 
|  | 18 | characterSet: 'windows-1252', | 
|  | 19 | contentType: 'text/html' | 
|  | 20 | }, | 
|  | 21 | {file: 'resources/utf-32-big-endian-bom.xml', | 
|  | 22 | characterSet: 'UTF-8', | 
|  | 23 | contentType: 'application/xml' | 
|  | 24 | }, | 
|  | 25 | {file: 'resources/utf-32-big-endian-nobom.html', | 
|  | 26 | characterSet: 'windows-1252', | 
|  | 27 | contentType: 'text/html' | 
|  | 28 | }, | 
|  | 29 | {file: 'resources/utf-32-big-endian-nobom.xml', | 
|  | 30 | characterSet: 'UTF-8', | 
|  | 31 | contentType: 'application/xml' | 
|  | 32 | }, | 
|  | 33 |  | 
|  | 34 | {file: 'resources/utf-32-little-endian-bom.html', | 
|  | 35 | characterSet: 'UTF-16LE', | 
|  | 36 | contentType: 'text/html' | 
|  | 37 | }, | 
|  | 38 | {file: 'resources/utf-32-little-endian-bom.xml', | 
|  | 39 | characterSet: 'UTF-16LE', | 
|  | 40 | contentType: 'application/xml' | 
|  | 41 | }, | 
|  | 42 | {file: 'resources/utf-32-little-endian-nobom.html', | 
|  | 43 | characterSet: 'windows-1252', | 
|  | 44 | contentType: 'text/html' | 
|  | 45 | }, | 
|  | 46 | {file: 'resources/utf-32-little-endian-nobom.xml', | 
|  | 47 | characterSet: 'UTF-8', | 
|  | 48 | contentType: 'application/xml' | 
|  | 49 | } | 
|  | 50 | ]; | 
|  | 51 |  | 
|  | 52 | samples.forEach(expected => async_test(t => { | 
|  | 53 | const iframe = document.createElement('iframe'); | 
|  | 54 | iframe.src = expected.file; | 
|  | 55 | iframe.onload = t.step_func_done(() => { | 
|  | 56 | const doc = iframe.contentDocument; | 
|  | 57 | assert_equals(doc.contentType, expected.contentType); | 
|  | 58 | assert_equals(doc.characterSet, expected.characterSet); | 
|  | 59 | // The following is a little quirky as non-well-formed XML isn't defined in sufficient detail to | 
|  | 60 | // be able to use more precise assertions. | 
|  | 61 | assert_true( | 
|  | 62 | !('dataset' in doc.documentElement) || | 
|  | 63 | doc.documentElement.dataset['parsed'] !== 'yes', | 
|  | 64 | 'Should not have parsed as (X)HTML'); | 
|  | 65 | }); | 
|  | 66 | document.body.appendChild(iframe); | 
|  | 67 | t.add_cleanup(() => iframe.remove()); | 
|  | 68 | }, `Expect ${expected.file} to parse as ${expected.characterSet}`)); | 
|  | 69 |  | 
|  | 70 | </script> | 
|  | 71 | </body> |