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

revived the navigator.id.channel, as well as the #NATIVE and #INTERNAL...

revived the navigator.id.channel, as well as the #NATIVE and #INTERNAL indications that internal APIs are about to be called
parent b6423f63
No related branches found
No related tags found
No related merge requests found
...@@ -74,6 +74,18 @@ BrowserID.Modules.Dialog = (function() { ...@@ -74,6 +74,18 @@ BrowserID.Modules.Dialog = (function() {
function startChannel() { function startChannel() {
var self = this; var self = this;
// first, we see if there is a local channel
if (win.navigator.id && win.navigator.id.channel) {
win.navigator.id.channel.registerController(self);
return;
}
// next, we see if the caller intends to call native APIs
if (win.location.hash == "#NATIVE" || win.location.hash == "#INTERNAL") {
// don't do winchan, let it be.
return;
}
try { try {
// //
WinChan.onOpen(function(origin, args, cb) { WinChan.onOpen(function(origin, args, cb) {
......
...@@ -72,10 +72,10 @@ ...@@ -72,10 +72,10 @@
}, },
location: { location: {
} },
} navigator: {},
};
function createController(config) { function createController(config) {
var config = $.extend({ var config = $.extend({
...@@ -116,6 +116,49 @@ ...@@ -116,6 +116,49 @@
}); });
}); });
asyncTest("initialization with add-on navigator.id.channel", function() {
var ok_p = false;
// expect registerController to be called.
winMock.navigator.id = {
channel : {
registerController: function(controller) {
ok_p = controller.getVerifiedEmail && controller.get;
}
}
};
createController({
ready: function() {
ok(ok_p, "registerController was not called with proper controller");
start();
}
});
});
asyncTest("initialization with #NATIVE", function() {
winMock.location.hash = "#NATIVE";
createController({
ready: function() {
ok($("#error .contents").text().length == 0, "no error should be reported");
start();
}
});
});
asyncTest("initialization with #INTERNAL", function() {
winMock.location.hash = "#INTERNAL";
createController({
ready: function() {
ok($("#error .contents").text().length == 0, "no error should be reported");
start();
}
});
});
/* /*
test("doXHRError while online, no network info given", function() { test("doXHRError while online, no network info given", function() {
createController(); createController();
......
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