mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
130 lines
3.9 KiB
HTML
130 lines
3.9 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for WebSMS</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
<iframe></iframe>
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
var defaultEnabled = ('mozMobileMessage' in frames[0].navigator);
|
|
|
|
/** Test for WebSMS **/
|
|
|
|
function checkSmsDisabled() {
|
|
ok(!('mozMobileMessage' in frames[0].navigator), "navigator.mozMobileMessage should not exist");
|
|
ok(frames[0].navigator.mozMobileMessage === undefined,
|
|
"navigator.mozMobileMessage should return undefined");
|
|
}
|
|
|
|
function checkSmsEnabled() {
|
|
// Bug 784617: WebSms is disabled on all platforms except Android for the moment.
|
|
if (navigator.appVersion.indexOf("Android") == -1 && SpecialPowers.Services.appinfo.name != "B2G") {
|
|
checkSmsDisabled();
|
|
return;
|
|
}
|
|
|
|
ok('mozMobileMessage' in frames[0].navigator, "navigator.mozMobileMessage should exist");
|
|
ok(frames[0].navigator.mozMobileMessage, "navigator.mozMobileMessage returns an object");
|
|
ok(frames[0].navigator.mozMobileMessage instanceof MozMobileMessageManager,
|
|
"navigator.mozMobileMessage is an MobileMessageManager object");
|
|
}
|
|
|
|
function checkSmsDisabledOrEnabled() {
|
|
if (!defaultEnabled)
|
|
checkSmsDisabled();
|
|
else
|
|
checkSmsEnabled();
|
|
}
|
|
|
|
function checkInterface(aInterface) {
|
|
ok(!(aInterface in window), aInterface + " should be prefixed");
|
|
ok(("Moz" + aInterface) in window, aInterface + " should be prefixed");
|
|
}
|
|
|
|
function test() {
|
|
checkInterface("SmsMessage");
|
|
checkInterface("SmsEvent");
|
|
checkInterface("SmsFilter");
|
|
|
|
// If sms is disabled and permission is removed, sms is disabled.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() {
|
|
SpecialPowers.pushPermissions([{'type': 'sms', 'remove': true, 'context': document}], test2);
|
|
});
|
|
}
|
|
|
|
function test2() {
|
|
checkSmsDisabledOrEnabled();
|
|
|
|
// If sms is enabled and permission is removed, sms is disabled.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() {
|
|
SpecialPowers.pushPermissions([{'type': 'sms', 'remove': true, 'context': document}], test3);
|
|
});
|
|
}
|
|
|
|
function test3() {
|
|
checkSmsDisabledOrEnabled();
|
|
|
|
// If sms is disabled and permission is granted, sms is disabled.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() {
|
|
SpecialPowers.pushPermissions([{'type': 'sms', 'allow': true, 'context': document}], test4);
|
|
});
|
|
}
|
|
|
|
function test4() {
|
|
checkSmsDisabledOrEnabled();
|
|
|
|
// If sms is enabled and permission is granted, sms is enabled.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() {
|
|
SpecialPowers.pushPermissions([{'type': 'sms', 'allow': true, 'context': document}], test5);
|
|
});
|
|
}
|
|
|
|
function test5() {
|
|
checkSmsDisabledOrEnabled();
|
|
|
|
// Now, if sms are disabled with the pref, they will still be enabled.
|
|
// The page has to be reloaded.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, test6);
|
|
}
|
|
|
|
function test6() {
|
|
checkSmsDisabledOrEnabled();
|
|
|
|
var iframeElt = document.getElementsByTagName('iframe')[0];
|
|
iframeElt.addEventListener("load", function() {
|
|
iframeElt.removeEventListener("load", arguments.callee);
|
|
checkSmsEnabled();
|
|
|
|
iframeElt.addEventListener("load", function() {
|
|
iframeElt.removeEventListener("load", arguments.callee);
|
|
|
|
checkSmsDisabled();
|
|
|
|
SimpleTest.finish();
|
|
});
|
|
|
|
// Disabling sms takes effect on reload.
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", false]]}, function() {
|
|
frames[0].location.reload();
|
|
});
|
|
});
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.sms.enabled", true]]}, function() {
|
|
frames[0].location.reload();
|
|
});
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(test);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|