chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    // 'use strict';
    if (request.action && sender.tab) {
      switch (request.action) {
      case 'getSelection':
        sendResponse(window.getSelection().toString());
      }
    }
  });

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    // 'use strict';
    if (request.action && sender.id) {
      switch (request.action) {
      case 'getSelection':
        sendResponse(window.getSelection().toString());
      }
    }
  });

Fix confition to check sender
Fix confition to check sender

so sender.tab is optional.

http://developer.chrome.com/extensions/runtime.html#type-MessageSender
