<commit_before>key = "your API key here"

function getCurrentTabUrl(callback) {
  var queryInfo = {
    active: true,
    currentWindow: true
  };
  chrome.tabs.query(queryInfo, function(tabs) {
    var tab = tabs[0];
    var url = tab.url;
    console.assert(typeof url == 'string', 'tab.url should be a string');
    callback(url);
  });
}

function renderStatus(statusText) {
  document.getElementById('result').textContent = statusText;
}

function getShortURL(LongURL, callback, errorCallback) {
  var API_URL = 'https://www.googleapis.com/urlshortener/v1/url?fields=id&key=' + key;

  var xml = new XMLHttpRequest();
  xml.open('POST', API_URL, true);
  xml.setRequestHeader("Content-Type", "application/json");
  //console.log(Url, searchTerm);
  xml.send(JSON.stringify({"longUrl": LongURL}));

  xml.onload = function(){
    var response = xml.response;
    console.log(response);
    callback(response);
  };
}


document.addEventListener('DOMContentLoaded', function() {
  getCurrentTabUrl(function(url) {
    getShortURL(url, function(result) {
      result = JSON.parse(result);
      console.log(result.id);
      renderStatus(result.id);
      });
  });
});<commit_msg>Added test case<commit_after>var key = "your API key here";

function getCurrentTabUrl(callback) {
  var queryInfo = {
    active: true,
    currentWindow: true
  };
  chrome.tabs.query(queryInfo, function(tabs) {
    var tab = tabs[0];
    var url = tab.url;
    console.assert(typeof url == 'string', 'tab.url should be a string');
    callback(url);
  });
}

function renderStatus(statusText) {
  document.getElementById('result').textContent = statusText;
}

function getShortURL(LongURL, callback) {
  var API_URL = 'https://www.googleapis.com/urlshortener/v1/url?fields=id&key=' + key;

  var xml = new XMLHttpRequest();
  xml.open('POST', API_URL, true);
  xml.setRequestHeader("Content-Type", "application/json");
  //console.log(Url, searchTerm);
  xml.send(JSON.stringify({"longUrl": LongURL}));
  console.log(xml);
  xml.onload = function(){
    var response = xml.response;
    callback(response);
  };
}

document.addEventListener('DOMContentLoaded', function() {
  getCurrentTabUrl(function(url) {
    getShortURL(url, function(result) {
      result = JSON.parse(result);
      console.log(result.id);
      if (result.id === undefined){
        return renderStatus("Check your tab URL");
      };
      renderStatus(result.id);
      });
  });
});
{'fraction_non_alphanumeric': 0.15529219452390683, 'fraction_numerical': 0.0016346546791990192, 'mean_word_length': 3.975609756097561, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 13}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4840753', 'n_tokens_mistral': 783, 'n_tokens_neox': 772, 'n_words': 152}