6
6
window.Unity = external.getUnityObject(1);
9
* Validates the page for functional tests.
13
if (!getProfileLinkNode() || !getProfileLinkNode().href) {
16
if (!checkMessagesCount().length) {
20
reportTestState('PASS SELF TEST');
23
function getProfileLinkNode() {
24
return document.evaluate('//a[@data-nav="profile"]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
8
27
function isCorrectPage() {
9
28
var i, ids = ['doc', 'banners', 'page-outer', 'global-nav-home', 'global-new-tweet-button'];
39
var currentIndicator = '';
41
function checkMessagesCount() {
44
var search = document.getElementsByClassName('search-query')[0];
45
if (search) { // stream for #tag
46
title = search.textContent;
48
if (document.getElementsByClassName('module mini-profile')[0]) { // home screen
54
var countElement = document.getElementsByClassName('new-tweets-bar js-new-tweets-bar')[0];
56
count = countElement.textContent.match(/\d+/)[0];
58
reportTestState(title + count);
59
// empty callback raise current tab
60
indicators.push({ name: title, count: count, callback: function () {} });
61
currentIndicator = title;
20
66
function messagingIndicatorSetup() {
21
function checkMessangesCount() {
23
var search = document.getElementsByClassName('search-query')[0];
24
if (search) { // stream for #tag
25
title = search.textContent;
27
if (document.getElementsByClassName('module mini-profile')[0]) { // home screen
33
var countElement = document.getElementsByClassName('new-tweets-bar js-new-tweets-bar')[0];
35
count = countElement.textContent.match(/\d+/)[0];
37
// empty callback raise current tab
38
reportTestState(title + count);
39
Unity.MessagingIndicator.showIndicator(title, { count: count,
40
callback: function () {} });
43
setInterval(wrapCallback(checkMessangesCount), 3000);
67
var indicatorsController = new Indicators(checkMessagesCount, true);
68
indicatorsController.visited(currentIndicator);
48
73
if (isCorrectPage()) {
49
74
var prefix = 'https://twitter.com/';
51
var profileLink = document.evaluate('//a[@data-nav="profile"]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
52
login = profileLink.href;
76
var profileLink = getProfileLinkNode();
77
if (profileLink && profileLink.href) {
78
login = profileLink.href;
54
if (login.substr(0, prefix.length) === prefix) {
55
login = login.substr(prefix.length);
80
if (login.substr(0, prefix.length) === prefix) {
81
login = login.substr(prefix.length);
59
87
callback = wrapCallback(messagingIndicatorSetup);
61
91
Unity.init({ name: "Twitter",