   blob = new Blob([fs.readFileSync(path)])
   blob.name = path
   blob
+
+createFileSelectorElement = (callback) ->
+  fileSelectorElement = document.createElement 'span'
+  fileSelectorElement.style.display = 'none'
+  fileSelectorElement.click = showFileChooserDialog.bind this, callback
+  return fileSelectorElement
+
+# Exposed for iframe.
+window.createMenu = createMenu
+window.createFileSelectorElement = createFileSelectorElement

window.onload = ->
  # Use menu API to show context menu.
  InspectorFrontendHost.showContextMenuAtPoint = (x, y, items, document) ->
    createMenu items

  # Use dialog API to override file chooser dialog.
  WebInspector.createFileSelectorElement = (callback) ->
    fileSelectorElement = document.createElement 'span'
    fileSelectorElement.style.display = 'none'
    fileSelectorElement.click = showFileChooserDialog.bind this, callback
    return fileSelectorElement

convertToMenuTemplate = (items) ->
  template = []

          label: item.label
          enabled: item.enabled
      if item.id?
        transformed.click = -> DevToolsAPI.contextMenuItemSelected item.id
      template.push transformed
  template

createMenu = (x, y, items, document) ->
  remote = require 'remote'
  Menu = remote.require 'menu'

