Right now, the implementation is awkward due to it being implemented in ScriptExecutionContext instead of in Document and WorkerContext.
Created attachment 25734 [details] Patch for bug.
Comment on attachment 25734 [details] Patch for bug. r=me
Committed revision 38986.