Last active
August 29, 2015 14:04
-
-
Save jsantell/d0b84e8f20abb24a44d7 to your computer and use it in GitHub Desktop.
e10s frame script utils usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; | |
const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js" | |
function navigateInHistory(aTarget, aDirection, aWaitForTargetEvent = "navigate") { | |
// if e10s, use the message manager | |
if (Cu.isCrossProcessWrapper(content)) { | |
let mm = gBrowser.selectedBrowser.messageManager; | |
mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false); | |
mm.sendAsyncMessage("devtools:test:history", { direction: aDirection }); | |
} | |
// Otherwise just access content directly | |
else { | |
executeSoon(() => content.history[aDirection]()); | |
} | |
return once(aTarget, aWaitForTargetEvent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
frame script might not be loaded yet when you
sendAsyncMessage()
.. the simplest solution is to usesendSyncMessage()
from the frame script, and set up a message listener in the chrome code that doesreturn { direction: aDirection }
.also, i don't think you need two code paths, you can just use the frame script in both cases, it works without e10s too..