validator/chromeextension/background.js
/**
 * Fetches the content of the tab's URL and validates it. Then updates the
 * extension's icons with pass/fail.
 *
 * @param {Tab} tab The Tab which triggered the event.
 */
Fetches the content of the tab's URL and validates it. Then updates the
extension's icons with pass/fail.

@param {Tab} tab The Tab which triggered the event.
Fetches the content of the tab ' s URL and validates it . Then updates the extension ' s icons with pass / fail . @param { Tab } tab The Tab which triggered the event .
function validateUrlFromTab(tab) {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', tab.url, true);
  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4) {
      const doc = xhr.responseText;
      const validationResult = amp.validator.validateString(doc);
      window.sessionStorage.setItem(tab.url, JSON.stringify(validationResult));
      if (validationResult.status == 'PASS') {
        handleAmpPass(tab.id, validationResult);
      } else {
        handleAmpFail(tab.id, validationResult);
      }
    }
  };
  xhr.send();
}
function validateUrlFromTab ( tab ) { var xhr = new XMLHttpRequest ( ) ; xhr . open ( 'GET' , tab . url , true ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState === 4 ) { const doc = xhr . responseText ; const validationResult = amp . validator . validateString ( doc ) ; window . sessionStorage . setItem ( tab . url , JSON . stringify ( validationResult ) ) ; if ( validationResult . status == 'PASS' ) { handleAmpPass ( tab . id , validationResult ) ; } else { handleAmpFail ( tab . id , validationResult ) ; } } } ; xhr . send ( ) ; }
Fetches the content of the tab's URL and validates it.
Fetches the content of the tab ' s URL and validates it .