CodeMirrorTestActors.sys.mjs (1116B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 let gCallback; 5 6 export class CodeMirrorTestParent extends JSWindowActorParent { 7 static setCallback(callback) { 8 gCallback = callback; 9 } 10 11 receiveMessage(message) { 12 if (gCallback) { 13 gCallback(message.name, message.data); 14 } 15 } 16 } 17 18 export class CodeMirrorTestChild extends JSWindowActorChild { 19 handleEvent(event) { 20 if (event.type == "DOMWindowCreated") { 21 this.contentWindow.wrappedJSObject.mozilla_setStatus = ( 22 statusMsg, 23 type, 24 customMsg 25 ) => { 26 this.sendAsyncMessage("setStatus", { 27 statusMsg, 28 type, 29 customMsg, 30 }); 31 }; 32 33 this.check(); 34 } 35 } 36 37 check() { 38 const doc = this.contentWindow.document; 39 const out = doc.getElementById("status"); 40 if (!out || !out.classList.contains("done")) { 41 this.contentWindow.setTimeout(() => this.check(), 100); 42 return; 43 } 44 45 this.sendAsyncMessage("done", { 46 failed: this.contentWindow.wrappedJSObject.failed, 47 }); 48 } 49 }