mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1577175 - Part 2: Add tests; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D44360 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
463e0e6d20
commit
d9f0623861
@ -24,7 +24,8 @@ BROWSER_CHROME_MANIFESTS += [
|
||||
|
||||
TEST_DIRS += [
|
||||
'gtest',
|
||||
'jsmodules'
|
||||
'jsmodules',
|
||||
'useractivation',
|
||||
]
|
||||
|
||||
TEST_HARNESS_FILES.testing.mochitest.tests.dom.base.test.chrome += [
|
||||
|
0
dom/base/test/useractivation/file_empty.html
Normal file
0
dom/base/test/useractivation/file_empty.html
Normal file
5
dom/base/test/useractivation/mochitest.ini
Normal file
5
dom/base/test/useractivation/mochitest.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
file_empty.html
|
||||
|
||||
[test_useractivation_has_been_activated.html]
|
9
dom/base/test/useractivation/moz.build
Normal file
9
dom/base/test/useractivation/moz.build
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MOCHITEST_MANIFESTS += [
|
||||
'mochitest.ini',
|
||||
]
|
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>User activation test: has been user gesture activated</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe></iframe>
|
||||
<iframe></iframe>
|
||||
<script>
|
||||
|
||||
function waitForEvent(aTarget, aEvent) {
|
||||
return new Promise((aResolve) => {
|
||||
aTarget.addEventListener(aEvent, function listener(event) {
|
||||
aResolve();
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function checkInitialStatus() {
|
||||
ok(!SpecialPowers.wrap(document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on top-level document");
|
||||
ok(!SpecialPowers.wrap(frames[0].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on first iframe");
|
||||
ok(!SpecialPowers.wrap(frames[1].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on second iframe");
|
||||
});
|
||||
|
||||
add_task(async function triggerUserActivation() {
|
||||
// Trigger user activation on the first iframe.
|
||||
SpecialPowers.wrap(frames[0].document).notifyUserGestureActivation();
|
||||
// We should also propagate to all the ancestors.
|
||||
ok(SpecialPowers.wrap(document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the top-level document");
|
||||
ok(SpecialPowers.wrap(frames[0].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the first iframe");
|
||||
ok(!SpecialPowers.wrap(frames[1].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the second iframe");
|
||||
});
|
||||
|
||||
add_task(async function iframeNavigation() {
|
||||
frames[0].frameElement.src = "file_empty.html";
|
||||
await waitForEvent(frames[0].frameElement, "load");
|
||||
// We should reset the flag on iframe that navigates away from current page,
|
||||
// but the flag on its ancestor isn't changed.
|
||||
ok(SpecialPowers.wrap(document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the top-level document");
|
||||
ok(!SpecialPowers.wrap(frames[0].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the first iframe");
|
||||
ok(!SpecialPowers.wrap(frames[1].document).hasBeenUserGestureActivated,
|
||||
"check has-been-user-activated on the second iframe");
|
||||
});
|
||||
|
||||
add_task(async function endTests() {
|
||||
// Reset the activation flag in order not to interfere following test in the
|
||||
// verify mode which would run the test using same document couple times.
|
||||
SpecialPowers.wrap(document).clearUserGestureActivation();
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
@ -563,6 +563,8 @@ partial interface Document {
|
||||
// For testing only.
|
||||
[ChromeOnly]
|
||||
void clearUserGestureActivation();
|
||||
[ChromeOnly]
|
||||
readonly attribute boolean hasBeenUserGestureActivated;
|
||||
};
|
||||
|
||||
// Extension to give chrome JS the ability to set an event handler which is
|
||||
|
Loading…
Reference in New Issue
Block a user