Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / subscribe_page_action / sniff_common.js
blob29e85f6a7760cfd517452ee91c26655b20a099cf
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The possible log levels.
6 var logLevels = {
7 "none": 0,
8 "error": 1,
9 "info": 2
12 // Defines the current log level. Values other than "none" are for debugging
13 // only and should at no point be checked in.
14 var currentLogLevel = logLevels.none;
16 function containsFeed(doc) {
17 debugMsg(logLevels.info, "containsFeed called");
19 // Find all the RSS link elements.
20 var result = doc.evaluate(
21 '//*[local-name()="rss" or local-name()="feed" or local-name()="RDF"]',
22 doc, null, 0, null);
24 if (!result) {
25 debugMsg(logLevels.info, "exiting: document.evaluate returned no results");
26 return false; // This is probably overly defensive, but whatever.
29 var node = result.iterateNext();
31 if (!node) {
32 debugMsg(logLevels.info, "returning: iterateNext() returned no nodes");
33 return false; // No RSS tags were found.
36 // The feed for arab dash jokes dot net, for example, contains
37 // a feed that is a child of the body tag so we continue only if the
38 // node contains no parent or if the parent is the body tag.
39 if (node.parentElement && node.parentElement.tagName != "BODY") {
40 debugMsg(logLevels.info, "exiting: parentElement that's not BODY");
41 return false;
44 debugMsg(logLevels.info, "Found feed");
46 return true;
49 function debugMsg(loglevel, text) {
50 if (loglevel <= currentLogLevel) {
51 console.log("RSS Subscription extension: " + text);