lang.https.html (2352B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Notification.lang</title> 4 <link rel="author" title="Apple Inc." href="http://www.apple.com/"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="resources/helpers.js"></script> 10 <script> 11 /* Validity and well-formedness was determined by using the BCP 47 12 Validator at http://schneegans.de/lv/ */ 13 14 /* The empty string is valid, as well as any valid BCP 47 language tag. */ 15 var valid_langs = ["", "en", "en-US-x-hixie", "de-DE", "de-de", "de-De", 16 "de-dE", "de-DE-1996", "de-Latn-DE", "de-Latf-DE", 17 "de-Latn-DE-1996", "de-CH", "it-CH", "fr-CH", 18 "rm-CH", "es-CH"]; 19 20 /* Well-formed but invalid BCP 47 language tags should not round-trip; 21 they should come back as the empty string. */ 22 var well_formed_langs = ["Latn-de", "Latf-de", "tic-tac-tac-toe", 23 "cocoa-1-bar", "cocoa-a-bar"]; 24 25 /* Invalid BCP 47 language tags should not round-trip; they should come 26 back as the empty string. */ 27 var invalid_langs = ["en-", "en-\-", "foo-\-bar", "id-\-\-Java", "fr-x", 28 "fr-xenomorph", "fr-x-xenomorph", "a", "a-fr-lang", 29 "b-fr-lang", "es1-KK-aa-bb-cc-dd", 30 "es2-KL-aa-bb-cc-dd", "es3-KM-aa-bb-cc-dd", "fooÉ", 31 "foöÉ-bÁr", "foöÉbÁr"]; 32 33 34 promise_setup(async () => { 35 // No need to show actual notification 36 await trySettingPermission("prompt"); 37 }); 38 39 function test_lang(language, should_passthrough) { 40 var expected = should_passthrough ? language : ""; 41 promise_test(async () => { 42 var notification = new Notification("This is a notification.", { 43 lang: language 44 }); 45 notification.close(); 46 assert_equals(notification.lang, expected, "notification.lang"); 47 }, 48 "Roundtripping lang \"" + language + "\". Expecting \"" + expected + "\"."); 49 } 50 51 for (var i=0; i<valid_langs.length; i++) { 52 test_lang(valid_langs[i], true); 53 } 54 55 for (var i=0; i<well_formed_langs.length; i++) { 56 test_lang(well_formed_langs[i], false); 57 } 58 59 for (var i=0; i<invalid_langs.length; i++) { 60 test_lang(invalid_langs[i], false); 61 } 62 </script>