toolkit/webapps/tests/app.sjs
author Sean Lin <selin@mozilla.com>
Fri, 30 May 2014 11:11:23 +0800
changeset 186401 3dd59dda51fce8a55862a61061a35dc61307d86e
parent 175493 6d2ffe8dc04699778a59491472d1532d59d5de9a
child 193715 89076de4e3c3e10ec5f22cdc85a9f737b65888f8
permissions -rw-r--r--
Bug 911242 - [LED] De-couple the control of screen backlight and keyboard backlight. r=dhylands, sr=sicking

function getQuery(request) {
  let query = {};

  request.queryString.split('&').forEach(function(val) {
    let [name, value] = val.split('=');
    query[name] = unescape(value);
  });

  return query;
}

function handleRequest(request, response) {
  response.setHeader("Cache-Control", "no-cache", false);

  let query = getQuery(request);

  if ("appreq" in query) {
    response.setHeader("Content-Type", "text/plain", false);
    response.write("Hello world!");

    setState("appreq", "done");

    return;
  }

  if ("testreq" in query) {
    response.setHeader("Content-Type", "text/plain", false);

    response.write(getState("appreq"));

    return;
  }
}