forked from mirrors/gecko-dev
MozReview-Commit-ID: K790Ag8WZgv --HG-- rename : browser/base/content/test/general/accounts_testRemoteCommands.html => browser/base/content/test/sync/accounts_testRemoteCommands.html rename : browser/base/content/test/general/browser_fxa_web_channel.html => browser/base/content/test/sync/browser_fxa_web_channel.html rename : browser/base/content/test/general/content_aboutAccounts.js => browser/base/content/test/sync/content_aboutAccounts.js extra : rebase_source : dcba087df94d06b15c9f073ff2df3324fd646c57
138 lines
3.2 KiB
HTML
138 lines
3.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>fxa_web_channel_test</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
var webChannelId = "account_updates_test";
|
|
|
|
window.onload = function() {
|
|
var testName = window.location.search.replace(/^\?/, "");
|
|
|
|
switch (testName) {
|
|
case "profile_change":
|
|
test_profile_change();
|
|
break;
|
|
case "login":
|
|
test_login();
|
|
break;
|
|
case "can_link_account":
|
|
test_can_link_account();
|
|
break;
|
|
case "logout":
|
|
test_logout();
|
|
break;
|
|
case "delete":
|
|
test_delete();
|
|
break;
|
|
}
|
|
};
|
|
|
|
function test_profile_change() {
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: webChannelId,
|
|
message: {
|
|
command: "profile:change",
|
|
data: {
|
|
uid: "abc123",
|
|
},
|
|
},
|
|
}),
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}
|
|
|
|
function test_login() {
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: webChannelId,
|
|
message: {
|
|
command: "fxaccounts:login",
|
|
data: {
|
|
authAt: Date.now(),
|
|
email: "testuser@testuser.com",
|
|
keyFetchToken: "key_fetch_token",
|
|
sessionToken: "session_token",
|
|
uid: "uid",
|
|
unwrapBKey: "unwrap_b_key",
|
|
verified: true,
|
|
},
|
|
messageId: 1,
|
|
},
|
|
}),
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}
|
|
|
|
function test_can_link_account() {
|
|
window.addEventListener("WebChannelMessageToContent", function(e) {
|
|
// echo any responses from the browser back to the tests on the
|
|
// fxaccounts_webchannel_response_echo WebChannel. The tests are
|
|
// listening for events and do the appropriate checks.
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: "fxaccounts_webchannel_response_echo",
|
|
message: e.detail.message,
|
|
})
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}, true);
|
|
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: webChannelId,
|
|
message: {
|
|
command: "fxaccounts:can_link_account",
|
|
data: {
|
|
email: "testuser@testuser.com",
|
|
},
|
|
messageId: 2,
|
|
},
|
|
}),
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}
|
|
|
|
function test_logout() {
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: webChannelId,
|
|
message: {
|
|
command: "fxaccounts:logout",
|
|
data: {
|
|
uid: "uid"
|
|
},
|
|
messageId: 3,
|
|
},
|
|
}),
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}
|
|
|
|
function test_delete() {
|
|
var event = new window.CustomEvent("WebChannelMessageToChrome", {
|
|
detail: JSON.stringify({
|
|
id: webChannelId,
|
|
message: {
|
|
command: "fxaccounts:delete",
|
|
data: {
|
|
uid: "uid"
|
|
},
|
|
messageId: 4,
|
|
},
|
|
}),
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|