   test "formatBold", (expectDocument) ->
     insertString("abc")
     getComposition().setSelectedRange([1, 2])
-    performInputTypeUsingExecCommand("bold", inputType: "formatBold")
-    defer ->
+    performInputTypeUsingExecCommand "bold", inputType: "formatBold", ->
       assert.textAttributes([0, 1], {})
       assert.textAttributes([1, 2], bold: true)
       assert.textAttributes([2, 3], {})

  test "formatItalic", (expectDocument) ->
    insertString("abc")
    getComposition().setSelectedRange([1, 2])
    performInputTypeUsingExecCommand("italic", inputType: "formatItalic")
    defer ->
      assert.textAttributes([0, 1], {})
      assert.textAttributes([1, 2], italic: true)
      assert.textAttributes([2, 3], {})

    inputEvents.push({type, inputType, data})

# Borrowed from https://github.com/web-platform-tests/wpt/blob/master/input-events/input-events-exec-command.html
performInputTypeUsingExecCommand = (command, {inputType, data}, callback) ->
  inputEvents = []
  requestAnimationFrame ->
    triggerInputEvent(document.activeElement, "beforeinput", {inputType, data})
    document.execCommand(command, false, data)
    assert.equal(inputEvents.length, 2)
    assert.equal(inputEvents[0].type, "beforeinput")
    assert.equal(inputEvents[1].type, "input")
    assert.equal(inputEvents[0].inputType, inputType)
    assert.equal(inputEvents[0].data, data)
    requestAnimationFrame(callback)

testGroup "Level 2 Input", testOptions, ->
  test "insertText", (expectDocument) ->
    performInputTypeUsingExecCommand "insertText", inputType: "insertText", data: "abc", ->
      expectDocument("abc\n")

  test "insertOrderedList", (expectDocument) ->
    insertString("abc")
    performInputTypeUsingExecCommand "insertOrderedList", inputType: "insertOrderedList", ->
      assert.blockAttributes([0, 4], ["numberList", "number"])
      assert.ok isToolbarButtonActive(attribute: "number")
      expectDocument("abc\n")

  test "insertUnorderedList", (expectDocument) ->
    insertString("abc")
    performInputTypeUsingExecCommand "insertUnorderedList", inputType: "insertUnorderedList", ->
      assert.blockAttributes([0, 4], ["bulletList", "bullet"])
      assert.ok isToolbarButtonActive(attribute: "bullet")
      expectDocument("abc\n")
