Skip to content

Instantly share code, notes, and snippets.

Forked from anonymous/iframe.js
Created December 11, 2012 21:55
Show Gist options
  • Save Gozala/4262598 to your computer and use it in GitHub Desktop.
Save Gozala/4262598 to your computer and use it in GitHub Desktop.
Updated version
let { Cc, Ci } = require('chrome');
let appShellService = Cc[';1'].
let service = Cc[";1"].
let window = appShellService.hiddenDOMWindow;
let document = window.document;
let XUL = ''
let frame = document.createElementNS(XUL, "browser");
frame.setAttribute("type", "content");
frame.setAttribute("src", "data:;charset=utf-8,");
let docShell = frame.docShell;
docShell.allowAuth = true;
docShell.allowJavascript = true;
docShell.allowPlugins = true;
// New platform capability is required to add window control
// For details see: Bug 635673
if ("allowWindowControl" in docShell)
docShell.allowWindowControl = false;
frame.setAttribute("flex", 1);
frame.setAttribute("transparent", "transparent");
frame.setAttribute("showcaret", true);
frame.setAttribute("clickthrough", "always");
frame.setAttribute("autocompleteenabled", true);
frame.setAttribute("autoscroll", true);
frame.setAttribute("src", "data:text/html,<script>" +
"setTimeout(function(){" +
"window.location='about:blank'" +
"},450);" +
frame.addEventListener("load", function(event) {
console.log("observe destruction of: ",;
let observeID = frame.contentWindow.
let observer = {
observe: function(subject, topic, data) {
let windowID = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
console.log("observe: ", observeID, " window: ", windowID)
if (windowID === observeID) {
console.log("<<<< unload >>>>")
service. removeObserver(observer, "inner-window-destroyed");
service.addObserver(observer, "inner-window-destroyed", false);
}, true)
info: scratch-kit: observe destruction of: data:text/html,<script>setTimeout(function(){window.location='about:blank'},450);</script>
info: scratch-kit: observe destruction of: about:blank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment