Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pccowboy/2551818 to your computer and use it in GitHub Desktop.
Save pccowboy/2551818 to your computer and use it in GitHub Desktop.
Test of createWindow from contextify, as used by jsdom
var window = new DOMWindow(options);
Contextify(window);
// We need to set up self references using Contextify's getGlobal() so that
// the global object identity is correct (window === this).
// See Contextify README for more info.
var global = window.getGlobal();
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
// Note: window.frames is maintained in the HTMLFrameElement init function.
window.window = window.frames
= window.self
= window.parent
= window.top = global;
var window = new DOMWindow(options);
Contextify(window);
// We need to set up self references using Contextify's getGlobal() so that
// the global object identity is correct (window === this).
// See Contextify README for more info.
var global = window.getGlobal();
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
// Note: window.frames is maintained in the HTMLFrameElement init function.
window.window = window.frames
= window.self
= window.parent
= window.top = global;
var window = new DOMWindow(options);
Contextify(window);
// We need to set up self references using Contextify's getGlobal() so that
// the global object identity is correct (window === this).
// See Contextify README for more info.
var global = window.getGlobal();
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
// Note: window.frames is maintained in the HTMLFrameElement init function.
window.window = window.frames
= window.self
= window.parent
= window.top = global;
var window = new DOMWindow(options);
Contextify(window);
// We need to set up self references using Contextify's getGlobal() so that
// the global object identity is correct (window === this).
// See Contextify README for more info.
var global = window.getGlobal();
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
// Note: window.frames is maintained in the HTMLFrameElement init function.
window.window = window.frames
= window.self
= window.parent
= window.top = global;
u=require('util')
j=require('node.io/node_modules/jsdom/lib/jsdom/browser/index.js')
w=j.createWindow('<html></html>',{})
u.puts(u.inspect(w.navigator))
{ userAgent: 'Node.js (linux; U; rv:v0.6.15)',
appName: 'Node.js jsDom',
platform: 'linux',
appVersion: 'v0.6.15' }
undefined
u.puts(u.inspect(w.window.navigator))
undefined
undefined
if (w === w.window) {u.puts('ok');} else {u.puts('not setting up global from contextify');}
not setting up global from contextify
undefined
@pccowboy
Copy link
Author

Sorry for the duplicate files from jsdom - gist seems to not want me to remove them, every time I try it seem to add another back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment