code: function onAccessApproved(sourceId) {
  
          pending = false;
          
          // if "cancel" button is clicked
          if(!sourceId || !sourceId.length) {
              return port.postMessage('PermissionDeniedError');
          }
          
          // "ok" button is clicked; share "sourceId" with the
          // content-script which will forward it to the webpage
          port.postMessage({
              chromeMediaSourceId: sourceId
          });
      }
docs: on getting sourceId "sourceId" will be empty if permission is denied.