Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 951950 Fix tests that don't run on Fennec, fix event/core iterati…
Browse files Browse the repository at this point in the history
…ng over invalid properties (localStorage) for Fennec's tab which accepts a window
  • Loading branch information
jsantell committed Jan 10, 2014
1 parent d59daa1 commit c5699b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
5 changes: 3 additions & 2 deletions lib/sdk/event/core.js
Expand Up @@ -161,9 +161,10 @@ function setListeners(target, listeners) {
Object.keys(listeners || {}).forEach(key => {
let match = EVENT_TYPE_PATTERN.exec(key);
let type = match && match[1].toLowerCase();
let listener = listeners[key];
if (!type) return;

if (type && typeof(listener) === 'function')
let listener = listeners[key];
if (typeof(listener) === 'function')
on(target, type, listener);
});
}
Expand Down
26 changes: 0 additions & 26 deletions test/test-windows-common.js
Expand Up @@ -5,11 +5,7 @@

const { Loader } = require('sdk/test/loader');
const { browserWindows } = require('sdk/windows');
const { viewFor } = require('sdk/view/core');
const { Ci } = require("chrome");
const { isBrowser, getWindowTitle } = require("sdk/window/utils");
const { defer } = require("sdk/lang/functional");


// TEST: browserWindows Iterator
exports.testBrowserWindowsIterator = function(assert) {
Expand Down Expand Up @@ -61,26 +57,4 @@ exports.testWindowActivateMethod_simple = function(assert) {
'Active tab is active after window.activate() call');
};


exports["test getView(window)"] = function(assert, done) {
browserWindows.once("open", window => {
const view = viewFor(window);

assert.ok(view instanceof Ci.nsIDOMWindow, "view is a window");
assert.ok(isBrowser(view), "view is a browser window");
assert.equal(getWindowTitle(view), window.title,
"window has a right title");

window.close();
// Defer handler cause window is destroyed after event is dispatched.
browserWindows.once("close", defer(_ => {
assert.equal(viewFor(window), null, "window view is gone");
done();
}));
});


browserWindows.open({ url: "data:text/html,<title>yo</title>" });
};

require('sdk/test').run(exports);
26 changes: 24 additions & 2 deletions test/windows/test-firefox-windows.js
Expand Up @@ -6,14 +6,16 @@
const { Cc, Ci } = require('chrome');
const { setTimeout } = require('sdk/timers');
const { Loader } = require('sdk/test/loader');
const { onFocus, getMostRecentWindow, windows } = require('sdk/window/utils');
const { onFocus, getMostRecentWindow, windows, isBrowser, getWindowTitle } = require('sdk/window/utils');
const { open, close, focus } = require('sdk/window/helpers');
const { browserWindows } = require("sdk/windows");
const tabs = require("sdk/tabs");
const winUtils = require("sdk/deprecated/window-utils");
const { WindowTracker } = winUtils;
const { isPrivate } = require('sdk/private-browsing');
const { isWindowPBSupported } = require('sdk/private-browsing/utils');
const { viewFor } = require("sdk/view/core");
const { defer } = require("sdk/lang/functional");

// TEST: open & close window
exports.testOpenAndCloseWindow = function(assert, done) {
Expand Down Expand Up @@ -418,6 +420,26 @@ exports.testWindowIteratorPrivateDefault = function(assert, done) {

close(window).then(done);
});
}
};

exports["test getView(window)"] = function(assert, done) {
browserWindows.once("open", window => {
const view = viewFor(window);

assert.ok(view instanceof Ci.nsIDOMWindow, "view is a window");
assert.ok(isBrowser(view), "view is a browser window");
assert.equal(getWindowTitle(view), window.title,
"window has a right title");

window.close();
// Defer handler cause window is destroyed after event is dispatched.
browserWindows.once("close", defer(_ => {
assert.equal(viewFor(window), null, "window view is gone");
done();
}));
});

browserWindows.open({ url: "data:text/html,<title>yo</title>" });
};

require('sdk/test').run(exports);

0 comments on commit c5699b7

Please sign in to comment.