Skip to content
Snippets Groups Projects
Commit 565ad859 authored by Ben Adida's avatar Ben Adida
Browse files

made new API calls fail when not called on navigator.id object

parent 5364153d
No related branches found
No related tags found
No related merge requests found
......@@ -1112,11 +1112,15 @@
navigator.id = {
request: function(options) {
if (this != navigator.id)
throw new Error("all navigator.id calls must be made on the navigator.id object");
options = options || {};
checkCompat(false);
return internalRequest(options);
},
watch: function(options) {
if (this != navigator.id)
throw new Error("all navigator.id calls must be made on the navigator.id object");
checkCompat(false);
internalWatch(options);
},
......@@ -1124,6 +1128,8 @@
// The callback parameter is DEPRECATED, instead you should use the
// the .onlogout observer of the .watch() api.
logout: function(callback) {
if (this != navigator.id)
throw new Error("all navigator.id calls must be made on the navigator.id object");
// allocate iframe if it is not allocated
_open_hidden_iframe();
// send logout message if the commChan exists
......
......@@ -24,5 +24,24 @@
});
});
test("DOM calls fails when unbound from navigator.id", function() {
_.each([
"watch",
"request",
"logout"
], function(item, index) {
var the_func = navigator.id[item];
var fails = false;
try {
the_func();
} catch (x) {
fails = true;
}
ok(fails);
});
});
}());
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment