Skip to content

Commit

Permalink
issue6778_experiment: just an experiment to find out the cause
Browse files Browse the repository at this point in the history
  • Loading branch information
fflorent committed Sep 14, 2013
1 parent 68c646e commit d4089a7
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions extension/content/firebug/console/consoleInjector.js
Expand Up @@ -15,7 +15,7 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;

const EXPOSED_CONSOLE_KEY = "fbConsoleExposed"+Math.random();
const EXPOSED_CONSOLE_KEY = "fbConsoleExposed" + Math.random();

// ********************************************************************************************* //
// Console Injector
Expand Down Expand Up @@ -59,26 +59,51 @@ Firebug.Console.injector =
var getConsoleWrapper = Cu.evalInSandbox(expr, sandbox);
var exposedConsole = getConsoleWrapper(console);

// xxxFlorent-Test: to be tested with http://jsfiddle.net/ekMtZ/embedded/result/
// xxxFlorent-Test: detect when win is the iframe (win.location = http://fiddle.jshell.net/ekMtZ/show/light/)
var isIframe = win.location.href.indexOf("shell") >= 0;
// Note: to early to use weakmap's + win.document in case of iframes. So we use an expando.

// xxxFlorent-Test: attempt to make win[EXPOSED_CONSOLE_KEY] non-writable,
// non-configurable for the iframe... But that doesn't work.
Object.defineProperty(win, EXPOSED_CONSOLE_KEY, {
configurable: true,
writable: true,
configurable: !isIframe,
writable: !isIframe,
enumerable: false,
value: exposedConsole
});
// xxxFlorent-Test: Detect when the property is deleted...
// Looks like it is quite immediately (~15/30 ms after)
if (isIframe)
{
var date = new Date();
(function a()
{
var time = (new Date() - date);
if (this.getExposedConsole(win))
{
setTimeout(a.bind(this), 4);
FBTrace.sysout("still okay after " + time + " ms");
}
else
FBTrace.sysout("disappeared after "+ time + " ms");

This comment has been minimized.

Copy link
@simonlindholm

simonlindholm Sep 14, 2013

maybe log the iframe location.href? obvious guess is that the deletion is part of navigation from about:blank to the real page

This comment has been minimized.

Copy link
@fflorent

fflorent Sep 14, 2013

Author Owner

done: 1f71256

}).call(this);
}
FBTrace.sysout("exposedConsole "+win.location.href, this.getExposedConsole(win));
win.wrappedJSObject.console = exposedConsole;
// xxxFlorent-Test: Just keep a reference to the iframe to play with it in the FBTrace
// console.
if (isIframe)
Firebug.iframe = win;

if (FBTrace.DBG_CONSOLE)
FBTrace.sysout("console.attachConsoleInjector; Firebug console attached to: " +
context.getName());
FBTrace.sysout("console.attachConsoleInjector; Firebug console attached to: " +
win.location.href);
}
catch (ex)
{
if (FBTrace.DBG_ERROR)
{
FBTrace.sysout("consoleInjector.attachConsoleInjector; exception while injecting",
ex);
}
ex.toString());
Firebug.iframeExc = win;
}
},

Expand Down

4 comments on commit d4089a7

@simonlindholm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you should log to fbtrace also when some navigation events / global creations happen?

@fflorent
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean using the "Global Events" tab of FBTrace?

Florent

@simonlindholm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like that, except I don't know if FBTrace records everything of important. We need inner window-level granularity.

@fflorent
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Simon.
If we go to "Global Events", and check "dom-window-destroyed", indeed we can see that the iframe window is getting destroyed after Firebug attaches the Console.

Maybe the use of watchWindow is wrong... I try a solution with DOMWindowCreated, and I let you know.

Florent

Please sign in to comment.