diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/notifications/lang.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/notifications/lang.html')
-rw-r--r-- | testing/web-platform/tests/notifications/lang.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/web-platform/tests/notifications/lang.html b/testing/web-platform/tests/notifications/lang.html new file mode 100644 index 000000000..be1795c8c --- /dev/null +++ b/testing/web-platform/tests/notifications/lang.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Notification.lang</title> +<link rel="author" title="Apple Inc." href="http://www.apple.com/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup({ explicit_done: true }); + +/* Validity and well-formedness was determined by using the BCP 47 + Validator at http://schneegans.de/lv/ */ + +/* The empty string is valid, as well as any valid BCP 47 language tag. */ +var valid_langs = ["", "en", "en-US-x-hixie", "de-DE", "de-de", "de-De", + "de-dE", "de-DE-1996", "de-Latn-DE", "de-Latf-DE", + "de-Latn-DE-1996", "de-CH", "it-CH", "fr-CH", + "rm-CH", "es-CH"]; + +/* Well-formed but invalid BCP 47 language tags should not round-trip; + they should come back as the empty string. */ +var well_formed_langs = ["Latn-de", "Latf-de", "tic-tac-tac-toe", + "cocoa-1-bar", "cocoa-a-bar"]; + +/* Invalid BCP 47 language tags should not round-trip; they should come + back as the empty string. */ +var invalid_langs = ["en-", "en-\-", "foo-\-bar", "id-\-\-Java", "fr-x", + "fr-xenomorph", "fr-x-xenomorph", "a", "a-fr-lang", + "b-fr-lang", "es1-KK-aa-bb-cc-dd", + "es2-KL-aa-bb-cc-dd", "es3-KM-aa-bb-cc-dd", "fooÉ", + "foöÉ-bÁr", "foöÉbÁr"]; + +function test_lang(language, should_passthrough) { + var expected = should_passthrough ? language : ""; + test(function() { + if (Notification.permission != "granted") { + this.force_timeout() + this.set_status(this.NOTRUN, "You must allow notifications for this origin before running this test.") + } + var notification = new Notification("This is a notification.", { + lang: language + }); + assert_equals(notification.lang, expected, "notification.lang"); + notification.onshow = function() { + notification.close(); + }; + }, + "Roundtripping lang \"" + language + "\". Expecting \"" + expected + "\"."); +} + +for (var i=0; i<valid_langs.length; i++) { + test_lang(valid_langs[i], true); +} + +for (var i=0; i<well_formed_langs.length; i++) { + test_lang(well_formed_langs[i], false); +} + +for (var i=0; i<invalid_langs.length; i++) { + test_lang(invalid_langs[i], false); +} + +done(); +</script> |