Skip to content

Commit

Permalink
Merge fx-team to m-c. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rvandermeulen committed Feb 19, 2015
2 parents f96b5df + 667fa91 commit ba7fc53
Show file tree
Hide file tree
Showing 83 changed files with 1,657 additions and 485 deletions.
7 changes: 3 additions & 4 deletions addon-sdk/source/lib/sdk/core/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ const ObserverDelegee = Class({
this.delegate = delegate;
},
QueryInterface: function(iid) {
const isObserver = iid.equals(Ci.nsIObserver);
const isWeakReference = iid.equals(Ci.nsISupportsWeakReference);

if (!isObserver && !isWeakReference)
if (!iid.equals(Ci.nsIObserver) &&
!iid.equals(Ci.nsISupportsWeakReference) &&
!iid.equals(Ci.nsISupports))
throw Cr.NS_ERROR_NO_INTERFACE;

return this;
Expand Down
7 changes: 7 additions & 0 deletions addon-sdk/source/lib/sdk/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ let hides = filter(panelEvents, ({type}) => type === "popuphidden");
let ready = filter(panelEvents, ({type, target}) =>
getAttachEventType(modelFor(panelFor(target))) === type);

// Panel event emitted when the contents of the panel has been loaded.
let readyToShow = filter(panelEvents, ({type}) => type === "DOMContentLoaded");

// Styles should be always added as soon as possible, and doesn't makes them
// depends on `contentScriptWhen`
let start = filter(panelEvents, ({type}) => type === "document-element-inserted");
Expand All @@ -317,6 +320,10 @@ on(ready, "data", ({target}) => {
let window = domPanel.getContentDocument(target).defaultView;

workerFor(panel).attach(window);
});

on(readyToShow, "data", ({target}) => {
let panel = panelFor(target);

if (!modelFor(panel).ready) {
modelFor(panel).ready = true;
Expand Down
13 changes: 10 additions & 3 deletions addon-sdk/source/test/addons/unsafe-content-script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
const { create: makeFrame } = require("sdk/frame/utils");
const { window } = require("sdk/addon/window");
const { Loader } = require('sdk/test/loader');
const loader = Loader(module);
const Worker = loader.require("sdk/content/worker").Worker;

exports.testMembranelessMode = function(assert, done) {
const loader = Loader(module);
const Worker = loader.require("sdk/content/worker").Worker;

let url = "data:text/html;charset=utf-8," + encodeURIComponent(
'<script>' +
Expand Down Expand Up @@ -48,13 +48,20 @@ exports.testMembranelessMode = function(assert, done) {
done();
}
});
worker.port.on("done", function () {

worker.port.on("done", () => {
// cleanup
element.parentNode.removeChild(element);
worker.destroy();
loader.unload();

done();
});

worker.port.on("assert", function (data) {
assert.ok(data.assertion, data.msg);
});

}
};

Expand Down
4 changes: 2 additions & 2 deletions addon-sdk/source/test/test-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports.testBufferMain = function (assert) {
// invalid encoding for Buffer.toString
assert.throws(() => {
b.toString('invalid');
}, TypeError, 'invalid encoding for Buffer.toString');
}, RangeError, 'invalid encoding for Buffer.toString');

// try to toString() a 0-length slice of a buffer, both within and without the
// valid buffer range
Expand Down Expand Up @@ -248,7 +248,7 @@ exports.testBufferWrite = function (assert) {

assert.throws(() => {
b.write('test string', 0, 5, 'invalid');
}, TypeError, 'invalid encoding with buffer write throws');
}, RangeError, 'invalid encoding with buffer write throws');
// try to write a 0-length string beyond the end of b
assert.throws(function() {
b.write('', 2048);
Expand Down
10 changes: 10 additions & 0 deletions addon-sdk/source/test/test-context-menu@2.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {openWindow, closeWindow, openTab, closeTab,
const {when} = require("sdk/dom/events");
const {Item, Menu, Separator, Contexts, Readers } = require("sdk/context-menu@2");
const prefs = require("sdk/preferences/service");
const { before, after } = require('sdk/test/utils');

const testPageURI = require.resolve("./test-context-menu").replace(".js", ".html");

Expand Down Expand Up @@ -1337,4 +1338,13 @@ if (require("@loader/options").isNative) {
};
}

before(exports, (name, assert) => {
// Make sure Java doesn't activate
prefs.set("plugin.state.java", 0);
});

after(exports, (name, assert) => {
prefs.reset("plugin.state.java");
});

require("sdk/test").run(module.exports);
10 changes: 9 additions & 1 deletion addon-sdk/source/test/test-dev-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ exports["test Panel API"] = test(function*(assert) {
yield closeToolbox();

assert.equal(panel.readyState, "destroyed", "panel is destroyed");
});

myTool.destroy();
});

exports["test Panel communication"] = test(function*(assert) {
const MyPanel = Class({
Expand Down Expand Up @@ -150,6 +151,7 @@ exports["test Panel communication"] = test(function*(assert) {
yield closeToolbox();

assert.equal(panel.readyState, "destroyed", "panel is destroyed");
myTool.destroy();
});

exports["test communication with debuggee"] = test(function*(assert) {
Expand Down Expand Up @@ -233,6 +235,8 @@ exports["test communication with debuggee"] = test(function*(assert) {
yield closeToolbox();

assert.equal(panel.readyState, "destroyed", "panel is destroyed");

myTool.destroy();
});


Expand Down Expand Up @@ -267,6 +271,8 @@ exports["test viewFor panel"] = test(function*(assert) {
assert.equal(frame.contentDocument.URL, url, "is expected iframe");

yield closeToolbox();

myTool.destroy();
});


Expand Down Expand Up @@ -314,6 +320,8 @@ exports["test createView panel"] = test(function*(assert) {
assert.equal(frame.contentDocument.URL, url, "is expected iframe");

yield closeToolbox();

myTool.destroy();
});

require("sdk/test").run(exports);
62 changes: 61 additions & 1 deletion addon-sdk/source/test/test-observers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { Class } = require("sdk/core/heritage");
const { Cc, Ci, Cu } = require("chrome");
const { notifyObservers } = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const { defer } = require("sdk/core/promise");

const message = x => ({wrappedJSObject: x});

Expand Down Expand Up @@ -120,4 +121,63 @@ exports["test weak observers are GC-ed on unload"] = (assert, end) => {
});
};

require("sdk/test").run(exports);
exports["test weak observer unsubscribe"] = function*(assert) {
const loader = Loader(module);
const { Observer, observe, subscribe, unsubscribe } = loader.require("sdk/core/observer");
const { WeakReference } = loader.require("sdk/core/reference");

let sawNotification = false;
let firstWait = defer();
let secondWait = defer();

const WeakObserver = Class({
extends: Observer,
implements: [WeakReference],
observe: function() {
sawNotification = true;
firstWait.resolve();
}
});

const StrongObserver = Class({
extends: Observer,
observe: function() {
secondWait.resolve();
}
});

observe.define(Observer, (x, ...rest) => x.observe(...rest));

let weakObserver = new WeakObserver;
let strongObserver = new StrongObserver();
subscribe(weakObserver, "test-topic");
subscribe(strongObserver, "test-wait");

notifyObservers(null, "test-topic", null);
yield firstWait.promise;

assert.ok(sawNotification, "Should have seen notification before GC");
sawNotification = false;

yield loader.require("sdk/test/memory").gc();

notifyObservers(null, "test-topic", null);
notifyObservers(null, "test-wait", null);
yield secondWait.promise;

assert.ok(sawNotification, "Should have seen notification after GC");
sawNotification = false;

try {
unsubscribe(weakObserver, "test-topic");
unsubscribe(strongObserver, "test-wait");
assert.pass("Should not have seen an exception");
}
catch (e) {
assert.fail("Should not have seen an exception");
}

loader.unload();
};

require("sdk/test").run(exports);
19 changes: 18 additions & 1 deletion addon-sdk/source/test/test-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ exports["test panel addon global object"] = function*(assert) {
exports["test panel load doesn't show"] = function*(assert) {
let loader = Loader(module);

let showCount = 0;
let panel = loader.require("sdk/panel").Panel({
contentScript: "addEventListener('load', function(event) { self.postMessage('load'); });",
contentScriptWhen: "start",
Expand Down Expand Up @@ -1335,6 +1334,24 @@ exports["test panel load doesn't show"] = function*(assert) {
loader.unload();
}

exports["test Panel without contentURL and contentScriptWhen=start should show"] = function*(assert) {
let loader = Loader(module);

let panel = loader.require("sdk/panel").Panel({
contentScriptWhen: "start",
// No contentURL, the bug only shows up when contentURL is not explicitly set.
});

yield new Promise(resolve => {
panel.once("show", resolve);
panel.show();
});

assert.pass("Received show event");

loader.unload();
}

if (packaging.isNative) {
module.exports = {
"test skip on jpm": (assert) => assert.pass("skipping this file with jpm")
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/browser-sets.inc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<command id="Tools:WebIDE" oncommand="gDevToolsBrowser.openWebIDE();" disabled="true" hidden="true"/>
<command id="Tools:BrowserToolbox" oncommand="BrowserToolboxProcess.init();" disabled="true" hidden="true"/>
<command id="Tools:BrowserContentToolbox" oncommand="gDevToolsBrowser.openContentProcessToolbox();" disabled="true" hidden="true"/>
<command id="Tools:BrowserConsole" oncommand="HUDService.toggleBrowserConsole();"/>
<command id="Tools:BrowserConsole" oncommand="HUDService.openBrowserConsoleOrFocus();"/>
<command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();"/>
<command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();"/>
<command id="Tools:Eyedropper" oncommand="openEyedropper();"/>
Expand Down
42 changes: 21 additions & 21 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5480,29 +5480,29 @@
var event = document.createEvent("Events");
event.initEvent("select", true, true);
this.dispatchEvent(event);
}
this._selectedIndex = val;
this._selectedIndex = val;
switchPromise.then(() => {
// If we cannot find the tabpanel that we were trying to switch to, then
// it must have been removed before our Promise could be resolved. In
// that case, we just cancel the tab switch.
var updatedTabIndex = Array.indexOf(this.childNodes, newPanel);
if (updatedTabIndex == -1) {
gBrowser._cancelTabSwitch(toTab);
} else {
this.setAttribute("selectedIndex", updatedTabIndex);
gBrowser._finalizeTabSwitch(toTab, fromTab);
}
}, () => {
// If the promise rejected, that means we don't want to actually
// flip the deck, so we cancel the tab switch.
// We need to nullcheck the method we're about to call because
// the binding might be dead at this point.
if (gBrowser._cancelTabSwitch)
gBrowser._cancelTabSwitch(toTab);
});
switchPromise.then(() => {
// If we cannot find the tabpanel that we were trying to switch to, then
// it must have been removed before our Promise could be resolved. In
// that case, we just cancel the tab switch.
var updatedTabIndex = Array.indexOf(this.childNodes, newPanel);
if (updatedTabIndex == -1) {
gBrowser._cancelTabSwitch(toTab);
} else {
this.setAttribute("selectedIndex", updatedTabIndex);
gBrowser._finalizeTabSwitch(toTab, fromTab);
}
}, () => {
// If the promise rejected, that means we don't want to actually
// flip the deck, so we cancel the tab switch.
// We need to nullcheck the method we're about to call because
// the binding might be dead at this point.
if (gBrowser._cancelTabSwitch)
gBrowser._cancelTabSwitch(toTab);
});
}
return val;
]]>
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/general/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ skip-if = e10s
skip-if = e10s # Bug 1100664 - test relies on linkedBrowser.docShell
[browser_tabs_owner.js]
[browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js]
skip-if = !e10s && os == "linux" # Bug 994541 - Need OMTC enabled by default on Linux, or else we get blocked by an alert dialog when opening e10s window.
run-if = e10s
[browser_trackingUI.js]
support-files =
trackingPage.html
Expand Down
6 changes: 5 additions & 1 deletion browser/base/content/test/general/browser_readerMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ add_task(function* () {
readerButton.click();
yield promiseTabLoadEvent(tab);

ok(gBrowser.selectedBrowser.currentURI.spec.startsWith("about:reader"), "about:reader loaded after clicking reader mode button");
let readerUrl = gBrowser.selectedBrowser.currentURI.spec;
ok(readerUrl.startsWith("about:reader"), "about:reader loaded after clicking reader mode button");
is_element_visible(readerButton, "Reader mode button is present on about:reader");

is(gURLBar.value, readerUrl, "gURLBar value is about:reader URL");
is(gURLBar.textValue, url.substring("http://".length), "gURLBar is displaying original article URL");

readerButton.click();
yield promiseTabLoadEvent(tab);
is(gBrowser.selectedBrowser.currentURI.spec, url, "Original page loaded after clicking active reader mode button");
Expand Down
5 changes: 5 additions & 0 deletions browser/base/content/urlbarBindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
break;
}
}
} else {
let originalUrl = ReaderParent.parseReaderUrl(aValue);
if (originalUrl) {
returnValue = originalUrl;
}
}

// Set the actiontype only if the user is not overriding actions.
Expand Down
6 changes: 0 additions & 6 deletions browser/components/preferences/in-content/subdialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ let gSubDialog = {
// Wait for the stylesheets injected during DOMContentLoaded to load before showing the dialog
// otherwise there is a flicker of the stylesheet applying.
this._frame.addEventListener("load", this._onLoad.bind(this));

chromeBrowser.addEventListener("unload", function(aEvent) {
if (aEvent.target.location.href != "about:blank") {
this.close();
}
}.bind(this), true);
},

uninit: function() {
Expand Down
Loading

0 comments on commit ba7fc53

Please sign in to comment.