Skip to content

Commit

Permalink
Part 2: Adjust notification tests
Browse files Browse the repository at this point in the history
Fixing one test to set permission properly and another to not trigger external network request.

Differential Revision: https://phabricator.services.mozilla.com/D198957

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1878741
gecko-commit: 5ab2cff5dfceaa1f85f4aae5f963b92d65fa517a
gecko-reviewers: asuth, dom-worker-reviewers
  • Loading branch information
saschanaz authored and moz-wptsync-bot committed May 23, 2024
1 parent 19e4e97 commit feec485
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions notifications/idlharness.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ idl_test(
Notification: ['notification'],
});
self.notification = new Notification('title');
self.notification.close();
}
}
);
23 changes: 11 additions & 12 deletions notifications/lang.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<link rel="author" title="Apple Inc." href="http://www.apple.com/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/helpers.js"></script>
<script>
setup({ explicit_done: true });

/* Validity and well-formedness was determined by using the BCP 47
Validator at http://schneegans.de/lv/ */

Expand All @@ -29,20 +30,20 @@
"es2-KL-aa-bb-cc-dd", "es3-KM-aa-bb-cc-dd", "fooÉ",
"foöÉ-bÁr", "foöÉbÁr"];


promise_setup(async () => {
// No need to show actual notification
await trySettingPermission("prompt");
});

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.")
}
promise_test(async () => {
var notification = new Notification("This is a notification.", {
lang: language
});
notification.close();
assert_equals(notification.lang, expected, "notification.lang");
notification.onshow = function() {
notification.close();
};
},
"Roundtripping lang \"" + language + "\". Expecting \"" + expected + "\".");
}
Expand All @@ -58,6 +59,4 @@
for (var i=0; i<invalid_langs.length; i++) {
test_lang(invalid_langs[i], false);
}

done();
</script>

0 comments on commit feec485

Please sign in to comment.