mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-19 18:38:36 +00:00
159 lines
4.5 KiB
XML
159 lines
4.5 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!-- Any copyright is dedicated to the Public Domain.
|
|
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
|
|
|
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
|
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
title="Mozilla Bug 781379">
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
<!-- test results are displayed in the html:body -->
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=809213"
|
|
target="_blank">Mozilla Bug 809213</a>
|
|
</body>
|
|
|
|
<script type="application/javascript;version=1.8">
|
|
|
|
"use strict";
|
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Services.prefs.setIntPref("dom.phonenumber.substringmatching.BR", 8);
|
|
Services.prefs.setCharPref("ril.lastKnownSimMcc", "724");
|
|
|
|
var pm = SpecialPowers.Cc["@mozilla.org/permissionmanager;1"]
|
|
.getService(SpecialPowers.Ci.nsIPermissionManager);
|
|
|
|
pm.addFromPrincipal(window.document.nodePrincipal, "phonenumberservice",
|
|
SpecialPowers.Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
|
|
function onUnwantedSuccess() {
|
|
ok(false, "onUnwantedSuccess: shouldn't get here");
|
|
}
|
|
|
|
function onFailure() {
|
|
ok(false, "in on Failure!");
|
|
}
|
|
|
|
var req;
|
|
var index = 0;
|
|
var mozPhoneNumberService = window.navigator.mozPhoneNumberService;
|
|
ok(mozPhoneNumberService, "mozPhoneNumberService exists");
|
|
var steps = [
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("123", "123");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "same number");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("abcdef", "222333");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "normalize first number");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("abc333", "222def");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "normalize first and second number");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("1234567", "1234568");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, false, "different numbers should not match");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("1234567", "123456");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, false, "different length numbers should not match");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("1234567", "123456---");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, false, "invalid number should not match valid number");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("111", undefined);
|
|
req.onsuccess = function(e) {
|
|
is(req.result, false, "missing second argument should not match");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch(undefined, "111");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, false, "missing first argument should not match");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch(null, "");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "missing first argument should fuzzy match empty string");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("+552155555555", "2155555555");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "test internationalization of number");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function() {
|
|
req = mozPhoneNumberService.fuzzyMatch("aaa123456789", "zzzzz123456789");
|
|
req.onsuccess = function(e) {
|
|
is(req.result, true, "substring matching should be in effect");
|
|
next();
|
|
};
|
|
req.onerror = onFailure;
|
|
},
|
|
function () {
|
|
ok(true, "all done!\n");
|
|
SimpleTest.finish();
|
|
}
|
|
];
|
|
|
|
function next() {
|
|
ok(true, "Begin!");
|
|
if (index >= steps.length) {
|
|
ok(false, "Shouldn't get here!");
|
|
return;
|
|
}
|
|
try {
|
|
var i = index++;
|
|
steps[i]();
|
|
} catch(ex) {
|
|
ok(false, "Caught exception", ex);
|
|
}
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
addLoadEvent(next);
|
|
</script>
|
|
</window>
|