title: Uncaught TypeError: Cannot read property 'checked' of null from chrome.storage.get()
body: <p>When I try to load my Google Chrome extension into the browser, I get the above error for my options.js file:</p>
  
  <p><a href="https://i.stack.imgur.com/JioLl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JioLl.png" alt="enter image description here"></a></p>
  
  <p>Here are my options.js:</p>
  
  <pre><code>var email_addr = document.getElementById("email_addr");
  var email_password = document.getElementById("email_password");
  var registerButton = document.getElementById("register");
  var url = document.getElementById("url");
  var port = document.getElementById("port");
  var password = document.getElementById("password");
  var ecs_mode = document.getElementById("ecs_mode");
  var encrypt = document.getElementById("encrypt");
  var include_content = document.getElementById("include_content");
  var saveButton = document.getElementById("save");
  debugger;
  restore_settings();
    chrome.storage.sync.get({"emailAddr": email_addr.value, 
  "emailPassword": email_password.value, 
  "contentServerURL": url.value, 
  "contentServerPort": port.value, 
  "contentServerPassword": password.value,
  "ecs_mode": ecs_mode.checked,
  "encrypt": encrypt.checked,
  "include_content": include_content.checked},
  function() {
  // Update status to let user know settings were saved.
  var status = document.getElementById("status");
  status.innerHTML = "Settings Saved.";
  setTimeout(function() {
          status.innerHTML = "";
  }, 750);
  });
  
  function register_addr() {
  }
  
  // Saves settings to chrome.storage.
  function save_settings() {
    if (!password.value) return;
  
    chrome.storage.sync.set({"emailAddr": email_addr.value, 
  "emailPassword": email_password.value, 
  "contentServerURL": url.value, 
  "contentServerPort": port.value, 
  "contentServerPassword": password.value,
  "ecs_mode": ecs_mode.checked,
  "encrypt": encrypt.checked,
  "include_content": include_content.checked}, 
  function() {
    // Update status to let user know settings were saved.
  var status = document.getElementById("status");
  status.innerHTML = "Settings Saved.";
  setTimeout(function() {
          status.innerHTML = "";
  }, 750);
  });
  }
  
  // Restores select box state to saved value from localStorage.
  function restore_settings() {  
    chrome.storage.sync.get("emailAddr", function(val) {
  email_addr.value = val.emailAddr;
  });
    chrome.storage.sync.get("emailPassword", function(val) {
  email_password.value = val.emailPassword;
  });
    chrome.storage.sync.get("contentServerPassword", function(val) {
  password.value = val.contentServerPassword;
  });
    chrome.storage.sync.get("contentServerURL", function(val) {
  url.value = val.contentServerURL;
  });
    chrome.storage.sync.get("contentServerPort", function(val) {
  port.value = val.contentServerPort;
  });
    chrome.storage.sync.get("ecs_mode", function(val) {
  ecs_mode.checked = val.ecs_mode;
  });
    chrome.storage.sync.get("encrypt", function(val) {
  encrypt.checked = val.encrypt;
  });
    chrome.storage.sync.get("include_content", function(val) {
  include_content.checked = val.include_content;
  });
  registerButton.disabled = false;
  saveButton.disabled = false;
  }
  
  function ecs_mode_fn() {
  if (ecs_mode.checked) {
    encrypt.disabled = false;
    include_content.disabled = false;
  }
  else {
    encrypt.disabled = true;
    include_content.disabled = true;
  }
  }
  
  function toggleButton() {
  if (email_addr.value.length == 0) {
      registerButton.disabled = true;
      saveButton.disabled = true;
  }
  else {
      registerButton.disabled = false;
      saveButton.disabled = false;
  }
  }
  
  document.addEventListener('DOMContentReady', restore_settings);
  if (document.querySelector('#save, #ecs_mode, #save, #restore, #register') != null)         {
  document.querySelector('#ecs_mode').addEventListener('click', ecs_mode_fn);
  document.querySelector('#save').addEventListener('click', save_settings);
  document.querySelector('#restore').addEventListener('click', restore_settings);
  document.querySelector('#email_addr').addEventListener('keyup', toggleButton);
  document.querySelector('#register').addEventListener('click', register_addr);
  }
  </code></pre>
  
  <p>options.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;title&gt;ECS Extension Settings&lt;/title&gt;
   &lt;style type="text/css"&gt;
      body {
          width: 800px;
          height: 200px;
   }
  &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;center&gt;&lt;h1&gt;ECS Content Server Settings&lt;/h1&gt;&lt;/center&gt;
  &lt;div title="Enter your e-mail address and password here. The address can be a     regular Gmail address ('&lt;someone&gt;@gmail.com') or an e-mail address associated with a Google business account."&gt;
  &lt;b&gt;Your e-mail address:&lt;/b&gt;
  &lt;input type="text" id="email_addr"&gt;
  &lt;b&gt;Password:&lt;/b&gt;
  &lt;input type="password" id="email_password"&gt;
  &lt;button id="register" disabled&gt;Register&lt;/button&gt;
  &lt;/div&gt;
  &lt;br&gt;
  After entering your e-mail address and password, press the &lt;b&gt;Register&lt;/b&gt; button to register your address with the ChiaraMail content server. You will then be sent a registration confirmation e-mail containing a link. Select the link to show your content server password and enter the password in the &lt;b&gt;Content server password&lt;/b&gt; field below.
  &lt;p&gt;
  &lt;div title="The name and port number of the content server are fixed. Enter the password you were assigned during registration. You may change your password later at https://www.chiaramail.com/login.jsp"&gt;
  &lt;b&gt;Content server URL:&lt;/b&gt;
  &lt;input type="text" id="url" value="www.chiaramail.com" disabled&gt;
  &lt;b&gt;Content server port:&lt;/b&gt;
  &lt;input type="text" id="port" value="443" size="4" disabled&gt;
  &lt;b&gt;Content server password:&lt;/b&gt;
  &lt;input type="password" id="password" maxlength="8" size="8"&gt;
  &lt;p&gt;
  &lt;/div&gt;
  &lt;div title="Check the 'Send as ECS' box if you want to send e-mail by default using the ECS technology. You will have the option of changing this setting when you compose your message."&gt;
  &lt;b&gt;Send as ECS: &lt;/b&gt;
  &lt;input type="checkbox" id="ecs_mode" checked&gt;
  &lt;/div&gt;
  &lt;div title="Check the 'Encrypt message' box if you want the message to be stored encrypted on the content server. You will have the option of changing this setting when you compose your message."&gt;
  &lt;b&gt;Encrypt message: &lt;/b&gt;
  &lt;input type="checkbox" id="encrypt"&gt;
  &lt;/div&gt;
  &lt;div title="Check the 'Include content' box if you want the message content to be sent along with the mail headers (useful when sending to mixed recipients, some enabled for ECS and others who are not). You will have the option of changing this setting when you compose your message."&gt;
  &lt;b&gt;Include content: &lt;/b&gt;
  &lt;input type="checkbox" id="include_content" checked&gt;
  &lt;/div&gt;
  &lt;!--&lt;div title="Select the 'Show ECS users' box to display message senders in magenta if the sender's e-mail address is registered with the ChiaraMail content server. This enables you to know which of your recipients are able to read ECS messages, but setting this option may adversely affect performance."&gt;
  &lt;p&gt;
  &lt;b&gt;Show ECS users:&lt;/b&gt;
  &lt;input type="checkbox" id="ecsusers" checked&gt;--&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;div id="status"&gt;&lt;/div&gt;
  &lt;div title="Press 'Save settings' to save your settings and 'Restore settings' to display them. Changes made to your account are propagated to all your devices and systems."&gt;
  &lt;button id="save" disabled&gt;Save settings&lt;/button&gt;
  &lt;button id="restore"&gt;Restore settings&lt;/button&gt;
  &lt;/div&gt;
  &lt;script src="options.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and manifest.json:</p>
  
  <pre><code>"name": "Envelope-Content Splitting (ECS) Support for Gmail",
  "version": "1.0",
  "manifest_version": 2,
  "description": "Add ECS support for Gmail running in Chrome. This enables Gmail users who access their accounts via the Google Chrome browser to send and read ECS mail. Check out http://www.chiaramail.com for information about ECS and for links to other FREE ECS-enabled mail clients and extensions.",
  "browser_action": {
  "default_icon": {"19": "ecs_icon_19.png", "38": "ecs_icon_38.png"},
  "default_title": "Press here to configure ECS settings",
  "default_popup": "options.html"
  },
  "options_page": "options.html",
  "icons": { "16": "ecs_icon_16.png", "48": "ecs_icon_48.png", "128":     "ecs_icon_128.png"},
  "background": {
  "scripts": ["background.js"]
  },
  "content_scripts": [
  {
  "run_at": "document_idle",
  "matches": ["https://mail.google.com/mail/*"],
  "js": ["updateContent.js", "colorHeaders.js", "renderContent.js", "sendOptions.js",     "base64.js", "jsaes.js"]
  }
  ],
  "permissions": ["tabs",
  "activeTab",
  "storage",
  "https://mail.google.com/mail/*"],
  "content_security_policy": "script-src 'self' https://www.chiaramail.com; object-src 'self'"
  }
  </code></pre>
  
  <p>I suspect the problem is with the way I coded chrome.storage.get(), but I couldn't find the API reference, <a href="https://developer.chrome.com/extensions/storage" rel="nofollow noreferrer">only an example of how to call it</a>. I'm pretty sure I coded the call to chrome.storage.get() correctly, though. What am I missing?</p>