     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}) ->
+performInputTypeUsingExecCommand = (command, {inputType, data}, callback) ->
   inputEvents = []
-  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 ->
+    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")
-    defer ->
+    performInputTypeUsingExecCommand "insertText", inputType: "insertText", data: "abc", ->
       expectDocument("abc\n")
 
   test "insertOrderedList", (expectDocument) ->
     insertString("abc")
-    performInputTypeUsingExecCommand("insertOrderedList", inputType: "insertOrderedList")
-    defer ->
+    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")
-    defer ->
+    performInputTypeUsingExecCommand "insertUnorderedList", inputType: "insertUnorderedList", ->
       assert.blockAttributes([0, 4], ["bulletList", "bullet"])
       assert.ok isToolbarButtonActive(attribute: "bullet")
       expectDocument("abc\n")

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

  test "insertLineBreak", (expectDocument) ->
    clickToolbarButton attribute: "quote", ->
      insertString("abc")
      performInputTypeUsingExecCommand "insertLineBreak", inputType: "insertLineBreak", ->
        performInputTypeUsingExecCommand "insertLineBreak", inputType: "insertLineBreak", ->
          assert.blockAttributes([0, 6], ["quote"])
          expectDocument("abc\n\n\n")

  test "insertParagraph", (expectDocument) ->
    clickToolbarButton attribute: "quote", ->
      insertString("abc")
      performInputTypeUsingExecCommand "insertParagraph", inputType: "insertParagraph", ->
        performInputTypeUsingExecCommand "insertParagraph", inputType: "insertParagraph", ->
          assert.blockAttributes([0, 4], ["quote"])
          assert.blockAttributes([4, 5], [])
          expectDocument("abc\n\n")
