Merge mozilla-central into services-central

This commit is contained in:
Gregory Szorc 2012-08-09 13:12:18 -07:00
commit 6d85cdb9be
415 changed files with 5071 additions and 3064 deletions

View File

@ -15,7 +15,7 @@ Cu.import("resource://gre/modules/Services.jsm");
function AlertsService() { } function AlertsService() { }
AlertsService.prototype = { AlertsService.prototype = {
classID: Components.ID("{5dce03b2-8faa-4b6e-9242-6ddb0411750c}"), classID: Components.ID("{fe33c107-82a4-41d6-8c64-5353267e04c9}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAlertsService]), QueryInterface: XPCOMUtils.generateQI([Ci.nsIAlertsService]),
showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable, aCookie, aAlertListener, aName) { showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable, aCookie, aAlertListener, aName) {

View File

@ -7,8 +7,8 @@ contract @mozilla.org/b2g-camera-content;1 {eff4231b-abce-4f7f-a40a-d646e8fde3ce
category JavaScript-navigator-property mozCamera @mozilla.org/b2g-camera-content;1 category JavaScript-navigator-property mozCamera @mozilla.org/b2g-camera-content;1
# AlertsService.js # AlertsService.js
component {5dce03b2-8faa-4b6e-9242-6ddb0411750c} AlertsService.js component {fe33c107-82a4-41d6-8c64-5353267e04c9} AlertsService.js
contract @mozilla.org/alerts-service;1 {5dce03b2-8faa-4b6e-9242-6ddb0411750c} contract @mozilla.org/system-alerts-service;1 {fe33c107-82a4-41d6-8c64-5353267e04c9}
# ContentPermissionPrompt.js # ContentPermissionPrompt.js
component {8c719f03-afe0-4aac-91ff-6c215895d467} ContentPermissionPrompt.js component {8c719f03-afe0-4aac-91ff-6c215895d467} ContentPermissionPrompt.js

View File

@ -15,7 +15,7 @@ function ContentPermissionPrompt() {}
ContentPermissionPrompt.prototype = { ContentPermissionPrompt.prototype = {
handleExistingPermission: function handleExistingPermission(request) { handleExistingPermission: function handleExistingPermission(request) {
let result = Services.perms.testExactPermission(request.uri, request.type); let result = Services.perms.testExactPermissionFromPrincipal(request.principal, request.type);
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) { if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
request.allow(); request.allow();
return true; return true;
@ -56,7 +56,7 @@ ContentPermissionPrompt.prototype = {
"type": "permission-prompt", "type": "permission-prompt",
"permission": request.type, "permission": request.type,
"id": requestId, "id": requestId,
"url": request.uri.spec "url": request.principal.URI.spec
}; };
let event = content.document.createEvent("CustomEvent"); let event = content.document.createEvent("CustomEvent");
event.initCustomEvent("mozChromeEvent", true, true, details); event.initCustomEvent("mozChromeEvent", true, true, details);

View File

@ -231,7 +231,7 @@ var gPluginHandler = {
managePlugins: function (aEvent) { managePlugins: function (aEvent) {
BrowserOpenAddonsMgr("addons://list/plugin"); BrowserOpenAddonsMgr("addons://list/plugin");
}, },
// Callback for user clicking on the link in a click-to-play plugin // Callback for user clicking on the link in a click-to-play plugin
// (where the plugin has an update) // (where the plugin has an update)
openPluginUpdatePage: function (aEvent) { openPluginUpdatePage: function (aEvent) {
@ -279,9 +279,8 @@ var gPluginHandler = {
// The overlay is null if the XBL binding is not attached (element is display:none). // The overlay is null if the XBL binding is not attached (element is display:none).
if (overlay) { if (overlay) {
overlay.addEventListener("click", function(aEvent) { overlay.addEventListener("click", function(aEvent) {
// Have to check that the target is a XULElement and not the link // Have to check that the target is not the link to update the plugin
// to update the plugin if (!(aEvent.originalTarget instanceof HTMLAnchorElement) &&
if (aEvent.target instanceof XULElement &&
aEvent.button == 0 && aEvent.isTrusted) aEvent.button == 0 && aEvent.isTrusted)
gPluginHandler.activateSinglePlugin(aEvent.target.ownerDocument.defaultView.top, aPlugin); gPluginHandler.activateSinglePlugin(aEvent.target.ownerDocument.defaultView.top, aPlugin);
}, true); }, true);

View File

@ -25,11 +25,6 @@ let gBrowserThumbnails = {
*/ */
_timeouts: null, _timeouts: null,
/**
* Cache for the PageThumbs module.
*/
_pageThumbs: null,
/** /**
* List of tab events we want to listen for. * List of tab events we want to listen for.
*/ */
@ -52,9 +47,6 @@ let gBrowserThumbnails = {
}, this); }, this);
this._timeouts = new WeakMap(); this._timeouts = new WeakMap();
XPCOMUtils.defineLazyModuleGetter(this, "_pageThumbs",
"resource:///modules/PageThumbs.jsm", "PageThumbs");
}, },
uninit: function Thumbnails_uninit() { uninit: function Thumbnails_uninit() {
@ -100,7 +92,7 @@ let gBrowserThumbnails = {
_capture: function Thumbnails_capture(aBrowser) { _capture: function Thumbnails_capture(aBrowser) {
if (this._shouldCapture(aBrowser)) if (this._shouldCapture(aBrowser))
this._pageThumbs.captureAndStore(aBrowser); PageThumbs.captureAndStore(aBrowser);
}, },
_delayedCapture: function Thumbnails_delayedCapture(aBrowser) { _delayedCapture: function Thumbnails_delayedCapture(aBrowser) {

View File

@ -140,6 +140,9 @@ XPCOMUtils.defineLazyGetter(this, "Social", function() {
return tmp.Social; return tmp.Social;
}); });
XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs",
"resource:///modules/PageThumbs.jsm");
#ifdef MOZ_SAFE_BROWSING #ifdef MOZ_SAFE_BROWSING
XPCOMUtils.defineLazyGetter(this, "SafeBrowsing", function() { XPCOMUtils.defineLazyGetter(this, "SafeBrowsing", function() {
let tmp = {}; let tmp = {};

View File

@ -3407,7 +3407,20 @@
// Set the cursor to an arrow during tab drags. // Set the cursor to an arrow during tab drags.
dt.mozCursor = "default"; dt.mozCursor = "default";
let canvas = tabPreviews.capture(tab, false); // Create a canvas to which we capture the current tab.
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
canvas.mozOpaque = true;
// We want drag images to be about 1/6th of the available screen width.
const widthFactor = 0.1739; // 1:5.75 inverse
canvas.width = Math.ceil(screen.availWidth * widthFactor);
// Maintain a 16:9 aspect ratio for drag images.
const aspectRatio = 0.5625; // 16:9 inverse
canvas.height = Math.round(canvas.width * aspectRatio);
let browser = tab.linkedBrowser;
PageThumbs.captureToCanvas(browser.contentWindow, canvas);
dt.setDragImage(canvas, 0, 0); dt.setDragImage(canvas, 0, 0);
// _dragOffsetX/Y give the coordinates that the mouse should be // _dragOffsetX/Y give the coordinates that the mouse should be

View File

@ -146,8 +146,7 @@ function test3() {
var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "class", "managePluginsLink"); var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "class", "managePluginsLink");
ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding"); ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding");
EventUtils.synthesizeMouse(manageLink, EventUtils.synthesizeMouseAtCenter(manageLink, {}, gTestBrowser.contentWindow);
5, 5, {}, gTestBrowser.contentWindow);
} }
function test4(tab, win) { function test4(tab, win) {
@ -237,7 +236,7 @@ function test9a() {
var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 9a, Plugin with id=" + plugin2.id + " should not be activated"); ok(!objLoadingContent.activated, "Test 9a, Plugin with id=" + plugin2.id + " should not be activated");
EventUtils.synthesizeMouse(plugin1, 100, 100, { }); EventUtils.synthesizeMouseAtCenter(plugin1, {}, gTestBrowser.contentWindow);
var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent);
var condition = function() objLoadingContent.activated; var condition = function() objLoadingContent.activated;
waitForCondition(condition, test9b, "Test 9a, Waited too long for plugin to activate"); waitForCondition(condition, test9b, "Test 9a, Waited too long for plugin to activate");
@ -266,7 +265,7 @@ function test9b() {
var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 9b, Plugin with id=" + plugin2.id + " should not be activated"); ok(!objLoadingContent.activated, "Test 9b, Plugin with id=" + plugin2.id + " should not be activated");
EventUtils.synthesizeMouse(plugin2, 100, 100, { }); EventUtils.synthesizeMouseAtCenter(plugin2, {}, gTestBrowser.contentWindow);
var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent);
var condition = function() objLoadingContent.activated; var condition = function() objLoadingContent.activated;
waitForCondition(condition, test9c, "Test 9b, Waited too long for plugin to activate"); waitForCondition(condition, test9c, "Test 9b, Waited too long for plugin to activate");
@ -482,7 +481,7 @@ function test16b() {
var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0];
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 16b, Plugin should not be activated"); ok(!objLoadingContent.activated, "Test 16b, Plugin should not be activated");
EventUtils.synthesizeMouse(plugin, 100, 100, { }); EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow);
var condition = function() objLoadingContent.activated; var condition = function() objLoadingContent.activated;
waitForCondition(condition, test16c, "Test 16b, Waited too long for plugin to activate"); waitForCondition(condition, test16c, "Test 16b, Waited too long for plugin to activate");
} }
@ -590,10 +589,18 @@ function test18a() {
test18b(); test18b();
} }
}; };
EventUtils.synthesizeMouse(updateLink, 5, 5, {}, gTestBrowser.contentWindow); EventUtils.synthesizeMouseAtCenter(updateLink, {}, gTestBrowser.contentWindow);
} }
function test18b() { function test18b() {
// clicking the update link should not activate the plugin
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 18b, Plugin should not be activated");
var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
ok(overlay.style.visibility != "hidden", "Test 18b, Plugin overlay should exist, not be hidden");
unregisterFakeBlocklistService(); unregisterFakeBlocklistService();
registerFakeBlocklistService(Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE); registerFakeBlocklistService(Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
prepareTest(test18c, gTestRoot + "plugin_test.html"); prepareTest(test18c, gTestRoot + "plugin_test.html");
@ -616,5 +623,71 @@ function test18c() {
var plugin = get_test_plugin(); var plugin = get_test_plugin();
plugin.clicktoplay = false; plugin.clicktoplay = false;
prepareTest(test19a, gTestRoot + "plugin_test.html");
}
// Tests that clicking the icon of the overlay activates the plugin
function test19a() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 19a, Plugin should not be activated");
var icon = doc.getAnonymousElementByAttribute(plugin, "class", "icon");
EventUtils.synthesizeMouseAtCenter(icon, {}, gTestBrowser.contentWindow);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test19b, "Test 19a, Waited too long for plugin to activate");
}
function test19b() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 19b, Plugin should be activated");
prepareTest(test19c, gTestRoot + "plugin_test.html");
}
// Tests that clicking the text of the overlay activates the plugin
function test19c() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 19c, Plugin should not be activated");
var text = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay");
EventUtils.synthesizeMouseAtCenter(text, {}, gTestBrowser.contentWindow);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test19d, "Test 19c, Waited too long for plugin to activate");
}
function test19d() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 19d, Plugin should be activated");
prepareTest(test19e, gTestRoot + "plugin_test.html");
}
// Tests that clicking the box of the overlay activates the plugin
// (just to be thorough)
function test19e() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(!objLoadingContent.activated, "Test 19e, Plugin should not be activated");
EventUtils.synthesizeMouse(plugin, 50, 50, {}, gTestBrowser.contentWindow);
var condition = function() objLoadingContent.activated;
waitForCondition(condition, test19f, "Test 19e, Waited too long for plugin to activate");
}
function test19f() {
var doc = gTestBrowser.contentDocument;
var plugin = doc.getElementById("test");
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
ok(objLoadingContent.activated, "Test 19f, Plugin should be activated");
finishTest(); finishTest();
} }

View File

@ -18,9 +18,7 @@ Browser context menu tests.
/** Test for Login Manager: multiple login autocomplete. **/ /** Test for Login Manager: multiple login autocomplete. **/
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); SpecialPowers.wrap(Components).utils.import("resource://gre/modules/InlineSpellChecker.jsm", window);
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
@ -729,7 +727,7 @@ function runTest(testNum) {
case 24: case 24:
// Context menu for selected text // Context menu for selected text
if (Services.appinfo.OS == "Darwin") { if (SpecialPowers.Services.appinfo.OS == "Darwin") {
// This test is only enabled on Mac due to bug 736399. // This test is only enabled on Mac due to bug 736399.
checkContextMenu(["context-copy", true, checkContextMenu(["context-copy", true,
"context-selectall", true, "context-selectall", true,
@ -745,7 +743,7 @@ function runTest(testNum) {
case 25: case 25:
// Context menu for selected text which matches valid URL pattern // Context menu for selected text which matches valid URL pattern
if (Services.appinfo.OS == "Darwin") { if (SpecialPowers.Services.appinfo.OS == "Darwin") {
// This test is only enabled on Mac due to bug 736399. // This test is only enabled on Mac due to bug 736399.
checkContextMenu(["context-openlinkincurrent", true, checkContextMenu(["context-openlinkincurrent", true,
"context-openlinkintab", true, "context-openlinkintab", true,
@ -790,8 +788,7 @@ var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
inputspell, pagemenu, dom_full_screen, plainTextItems, audio_in_video; inputspell, pagemenu, dom_full_screen, plainTextItems, audio_in_video;
function startTest() { function startTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); chromeWin = SpecialPowers.wrap(subwindow)
chromeWin = subwindow
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem) .QueryInterface(Ci.nsIDocShellTreeItem)

View File

@ -26,6 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462856
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.wrap(Components).classes;
var numFinished = 0; var numFinished = 0;
@ -34,18 +35,17 @@ window.addEventListener("message", function(event) {
if (++numFinished == 3) { if (++numFinished == 3) {
// Clean up after ourself // Clean up after ourself
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var pm = Cc["@mozilla.org/permissionmanager;1"].
var pm = Components.classes["@mozilla.org/permissionmanager;1"].
getService(Components.interfaces.nsIPermissionManager); getService(Components.interfaces.nsIPermissionManager);
var ioService = Components.classes["@mozilla.org/network/io-service;1"] var ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService); .getService(Components.interfaces.nsIIOService);
var uri1 = ioService.newURI(frames.testFrame.location, null, null); var uri1 = ioService.newURI(frames.testFrame.location, null, null);
var uri2 = ioService.newURI(frames.testFrame3.location, null, null); var uri2 = ioService.newURI(frames.testFrame3.location, null, null);
var principal1 = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal1 = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri1); .getNoAppCodebasePrincipal(uri1);
var principal2 = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal2 = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri2); .getNoAppCodebasePrincipal(uri2);
@ -108,8 +108,7 @@ function loaded() {
// Click the notification bar's "Allow" button. This should kick // Click the notification bar's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from // off updates, which will eventually lead to getting messages from
// the children. // the children.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var wm = SpecialPowers.wrap(Components).classes["@mozilla.org/appshell/window-mediator;1"].
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator); getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox(); var notificationBox = win.gBrowser.getNotificationBox();
@ -117,7 +116,7 @@ function loaded() {
var notification = notificationBox.getNotificationWithValue("offline-app-requested-mochi.test"); var notification = notificationBox.getNotificationWithValue("offline-app-requested-mochi.test");
notification.childNodes[0].click(); notification.childNodes[0].click();
notification = notificationBox.getNotificationWithValue("offline-app-requested-example.com"); notification = SpecialPowers.wrap(notificationBox).getNotificationWithValue("offline-app-requested-example.com");
notification.childNodes[0].click(); notification.childNodes[0].click();
} }

View File

@ -32,15 +32,13 @@ SimpleTest.waitForExplicitFinish();
function finishTest() { function finishTest() {
// Clean up after ourselves. // Clean up after ourselves.
netscape.security.PrivilegeManager var Cc = SpecialPowers.wrap(Components).classes;
.enablePrivilege("UniversalXPConnect"); var pm = Cc["@mozilla.org/permissionmanager;1"].
var pm = Components.classes["@mozilla.org/permissionmanager;1"].
getService(Components.interfaces.nsIPermissionManager); getService(Components.interfaces.nsIPermissionManager);
var uri = Components.classes["@mozilla.org/network/io-service;1"] var uri = Cc["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService)
.getService(Components.interfaces.nsIIOService)
.newURI(window.frames[0].location, null, null); .newURI(window.frames[0].location, null, null);
var principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"] var principal = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager) .getService(Components.interfaces.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri); .getNoAppCodebasePrincipal(uri);
@ -70,8 +68,6 @@ function handleMessageEvents(event) {
// successfully reloaded), or the string "error" appears // successfully reloaded), or the string "error" appears
// in the iframe, as in the case of bug 501422. // in the iframe, as in the case of bug 501422.
intervalID = setInterval(function() { intervalID = setInterval(function() {
netscape.security.PrivilegeManager
.enablePrivilege("UniversalXPConnect");
// Sometimes document.body may not exist, and trying to access // Sometimes document.body may not exist, and trying to access
// it will throw an exception, so handle this case. // it will throw an exception, so handle this case.
try { try {
@ -103,8 +99,7 @@ function loaded() {
// Click the notification bar's "Allow" button. This should kick // Click the notification bar's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from // off updates, which will eventually lead to getting messages from
// the iframe. // the iframe.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var wm = SpecialPowers.wrap(Components).classes["@mozilla.org/appshell/window-mediator;1"].
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator); getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox(); var notificationBox = win.gBrowser.getNotificationBox();

View File

@ -20,8 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589543
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var doc = SpecialPowers.wrap($("testFrame").contentDocument);
var doc = $("testFrame").contentDocument;
var daddy = doc.getElementById("feedSubscribeLine"); var daddy = doc.getElementById("feedSubscribeLine");
var popup = doc.getAnonymousElementByAttribute(daddy, "anonid", "handlersMenuPopup"); var popup = doc.getAnonymousElementByAttribute(daddy, "anonid", "handlersMenuPopup");
isnot(popup, null, "Feed preview should have a handlers popup"); isnot(popup, null, "Feed preview should have a handlers popup");

View File

@ -1560,13 +1560,14 @@ ContentPermissionPrompt.prototype = {
return; return;
} }
var requestingURI = request.uri; var requestingPrincipal = request.principal;
var requestingURI = requestingPrincipal.URI;
// Ignore requests from non-nsIStandardURLs // Ignore requests from non-nsIStandardURLs
if (!(requestingURI instanceof Ci.nsIStandardURL)) if (!(requestingURI instanceof Ci.nsIStandardURL))
return; return;
var result = Services.perms.testExactPermission(requestingURI, "geo"); var result = Services.perms.testExactPermissionFromPrincipal(requestingPrincipal, "geo");
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) { if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
request.allow(); request.allow();
@ -1619,7 +1620,7 @@ ContentPermissionPrompt.prototype = {
label: browserBundle.GetStringFromName("geolocation.alwaysShareLocation"), label: browserBundle.GetStringFromName("geolocation.alwaysShareLocation"),
accessKey: browserBundle.GetStringFromName("geolocation.alwaysShareLocation.accesskey"), accessKey: browserBundle.GetStringFromName("geolocation.alwaysShareLocation.accesskey"),
callback: function () { callback: function () {
Services.perms.add(requestingURI, "geo", Ci.nsIPermissionManager.ALLOW_ACTION); Services.perms.addFromPrincipal(requestingPrincipal, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
request.allow(); request.allow();
} }
}); });
@ -1627,7 +1628,7 @@ ContentPermissionPrompt.prototype = {
label: browserBundle.GetStringFromName("geolocation.neverShareLocation"), label: browserBundle.GetStringFromName("geolocation.neverShareLocation"),
accessKey: browserBundle.GetStringFromName("geolocation.neverShareLocation.accesskey"), accessKey: browserBundle.GetStringFromName("geolocation.neverShareLocation.accesskey"),
callback: function () { callback: function () {
Services.perms.add(requestingURI, "geo", Ci.nsIPermissionManager.DENY_ACTION); Services.perms.addFromPrincipal(requestingPrincipal, "geo", Ci.nsIPermissionManager.DENY_ACTION);
request.cancel(); request.cancel();
} }
}); });

View File

@ -116,11 +116,26 @@ let PageThumbs = {
return; return;
} }
let telemetryCaptureTime = new Date();
let [sw, sh, scale] = this._determineCropSize(aWindow);
let canvas = this._createCanvas(); let canvas = this._createCanvas();
let ctx = canvas.getContext("2d"); this.captureToCanvas(aWindow, canvas);
// Fetch the canvas data on the next event loop tick so that we allow
// some event processing in between drawing to the canvas and encoding
// its data. We want to block the UI as short as possible. See bug 744100.
Services.tm.currentThread.dispatch(function () {
canvas.mozFetchAsStream(aCallback, this.contentType);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
},
/**
* Captures a thumbnail from a given window and draws it to the given canvas.
* @param aWindow The DOM window to capture a thumbnail from.
* @param aCanvas The canvas to draw to.
*/
captureToCanvas: function PageThumbs_captureToCanvas(aWindow, aCanvas) {
let telemetryCaptureTime = new Date();
let [sw, sh, scale] = this._determineCropSize(aWindow, aCanvas);
let ctx = aCanvas.getContext("2d");
// Scale the canvas accordingly. // Scale the canvas accordingly.
ctx.scale(scale, scale); ctx.scale(scale, scale);
@ -136,13 +151,6 @@ let PageThumbs = {
let telemetry = Services.telemetry; let telemetry = Services.telemetry;
telemetry.getHistogramById("FX_THUMBNAILS_CAPTURE_TIME_MS") telemetry.getHistogramById("FX_THUMBNAILS_CAPTURE_TIME_MS")
.add(new Date() - telemetryCaptureTime); .add(new Date() - telemetryCaptureTime);
// Fetch the canvas data on the next event loop tick so that we allow
// some event processing in between drawing to the canvas and encoding
// its data. We want to block the UI as short as possible. See bug 744100.
Services.tm.currentThread.dispatch(function () {
canvas.mozFetchAsStream(aCallback, this.contentType);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}, },
/** /**
@ -193,13 +201,14 @@ let PageThumbs = {
/** /**
* Determines the crop size for a given content window. * Determines the crop size for a given content window.
* @param aWindow The content window. * @param aWindow The content window.
* @param aCanvas The target canvas.
* @return An array containing width, height and scale. * @return An array containing width, height and scale.
*/ */
_determineCropSize: function PageThumbs_determineCropSize(aWindow) { _determineCropSize: function PageThumbs_determineCropSize(aWindow, aCanvas) {
let sw = aWindow.innerWidth; let sw = aWindow.innerWidth;
let sh = aWindow.innerHeight; let sh = aWindow.innerHeight;
let [thumbnailWidth, thumbnailHeight] = this._getThumbnailSize(); let {width: thumbnailWidth, height: thumbnailHeight} = aCanvas;
let scale = Math.max(thumbnailWidth / sw, thumbnailHeight / sh); let scale = Math.max(thumbnailWidth / sw, thumbnailHeight / sh);
let scaledWidth = sw * scale; let scaledWidth = sw * scale;
let scaledHeight = sh * scale; let scaledHeight = sh * scale;

View File

@ -11,8 +11,6 @@ registerCleanupFunction(function () {
gBrowser.removeTab(gBrowser.tabs[1]); gBrowser.removeTab(gBrowser.tabs[1]);
}); });
let cachedXULDocument;
/** /**
* Provide the default test function to start our test runner. * Provide the default test function to start our test runner.
*/ */

View File

@ -51,15 +51,16 @@ let DebuggerController = {
window.removeEventListener("DOMContentLoaded", this._startupDebugger, true); window.removeEventListener("DOMContentLoaded", this._startupDebugger, true);
DebuggerView.initializePanes(); DebuggerView.initializePanes();
DebuggerView.initializeEditor(); DebuggerView.initializeEditor(function() {
DebuggerView.StackFrames.initialize(); DebuggerView.Scripts.initialize();
DebuggerView.Breakpoints.initialize(); DebuggerView.StackFrames.initialize();
DebuggerView.Properties.initialize(); DebuggerView.Breakpoints.initialize();
DebuggerView.Scripts.initialize(); DebuggerView.Properties.initialize();
DebuggerView.showCloseButton(!this._isRemoteDebugger && !this._isChromeDebugger); DebuggerView.showCloseButton(!this._isRemoteDebugger && !this._isChromeDebugger);
this.dispatchEvent("Debugger:Loaded"); this.dispatchEvent("Debugger:Loaded");
this._connect(); this._connect();
}.bind(this));
}, },
/** /**
@ -934,7 +935,7 @@ SourceScripts.prototype = {
// Select the preferred script if one exists, the first entry otherwise. // Select the preferred script if one exists, the first entry otherwise.
let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl; let preferredScriptUrl = DebuggerView.Scripts.preferredScriptUrl;
if (preferredScriptUrl) { if (preferredScriptUrl && DebuggerView.Scripts.contains(preferredScriptUrl)) {
DebuggerView.Scripts.selectScript(preferredScriptUrl); DebuggerView.Scripts.selectScript(preferredScriptUrl);
} else { } else {
DebuggerView.Scripts.selectIndex(0); DebuggerView.Scripts.selectIndex(0);

View File

@ -32,8 +32,11 @@ let DebuggerView = {
/** /**
* Initializes the SourceEditor instance. * Initializes the SourceEditor instance.
*
* @param function aCallback
* Called after the editor finishes initializing.
*/ */
initializeEditor: function DV_initializeEditor() { initializeEditor: function DV_initializeEditor(aCallback) {
let placeholder = document.getElementById("editor"); let placeholder = document.getElementById("editor");
let config = { let config = {
@ -45,7 +48,10 @@ let DebuggerView = {
}; };
this.editor = new SourceEditor(); this.editor = new SourceEditor();
this.editor.init(placeholder, config, this._onEditorLoad.bind(this)); this.editor.init(placeholder, config, function() {
this._onEditorLoad();
aCallback();
}.bind(this));
}, },
/** /**
@ -474,7 +480,7 @@ ScriptsView.prototype = {
for (let i = 0, l = scripts.itemCount; i < l; i++) { for (let i = 0, l = scripts.itemCount; i < l; i++) {
scripts.getItemAtIndex(i).hidden = false; scripts.getItemAtIndex(i).hidden = false;
} }
} else { } else if (this._prevSearchedFile !== file) {
let found = false; let found = false;
for (let i = 0, l = scripts.itemCount; i < l; i++) { for (let i = 0, l = scripts.itemCount; i < l; i++) {
@ -502,15 +508,18 @@ ScriptsView.prototype = {
scripts.removeAttribute("tooltiptext"); scripts.removeAttribute("tooltiptext");
} }
} }
if (line > -1) { if (this._prevSearchedLine !== line && line > -1) {
editor.setCaretPosition(line - 1); editor.setCaretPosition(line - 1);
} }
if (token.length) { if (this._prevSearchedToken !== token && token.length > 0) {
let offset = editor.find(token, { ignoreCase: true }); let offset = editor.find(token, { ignoreCase: true });
if (offset > -1) { if (offset > -1) {
editor.setSelection(offset, offset + token.length) editor.setSelection(offset, offset + token.length)
} }
} }
this._prevSearchedFile = file;
this._prevSearchedLine = line;
this._prevSearchedToken = token;
}, },
/** /**

View File

@ -44,6 +44,7 @@ MOCHITEST_BROWSER_TESTS = \
browser_dbg_stack-04.js \ browser_dbg_stack-04.js \
browser_dbg_stack-05.js \ browser_dbg_stack-05.js \
browser_dbg_location-changes.js \ browser_dbg_location-changes.js \
browser_dbg_location-changes-new.js \
browser_dbg_location-changes-blank.js \ browser_dbg_location-changes-blank.js \
browser_dbg_script-switching.js \ browser_dbg_script-switching.js \
browser_dbg_scripts-sorting.js \ browser_dbg_scripts-sorting.js \

View File

@ -0,0 +1,91 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure that changing the tab location URL to a page with other scripts works.
*/
var gPane = null;
var gTab = null;
var gDebuggee = null;
var gDebugger = null;
function test()
{
debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
gTab = aTab;
gDebuggee = aDebuggee;
gPane = aPane;
gDebugger = gPane.contentWindow;
testSimpleCall();
});
}
function testSimpleCall() {
gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
Services.tm.currentThread.dispatch({
run: function() {
var frames = gDebugger.DebuggerView.StackFrames._frames,
childNodes = frames.childNodes;
is(gDebugger.DebuggerController.activeThread.state, "paused",
"Should only be getting stack frames while paused.");
is(frames.querySelectorAll(".dbg-stackframe").length, 1,
"Should have only one frame.");
is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
"All children should be frames.");
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
testLocationChange();
}
}, 0);
});
gDebuggee.simpleCall();
}
function testLocationChange()
{
gDebugger.DebuggerController.activeThread.resume(function() {
gDebugger.DebuggerController.client.addOneTimeListener("tabNavigated", function(aEvent, aPacket) {
ok(true, "tabNavigated event was fired.");
gDebugger.DebuggerController.client.addOneTimeListener("tabAttached", function(aEvent, aPacket) {
ok(true, "Successfully reattached to the tab again.");
// Wait for the initial resume...
gDebugger.gClient.addOneTimeListener("resumed", function() {
isnot(gDebugger.DebuggerView.Scripts.selected, null,
"There should be a selected script.");
isnot(gDebugger.editor.getText().length, 0,
"The source editor should have some text displayed.");
let menulist = gDebugger.DebuggerView.Scripts._scripts;
let noScripts = gDebugger.L10N.getStr("noScriptsText");
isnot(menulist.getAttribute("label"), noScripts,
"The menulist should not display a notice that there are no scripts availalble.");
isnot(menulist.getAttribute("tooltiptext"), "",
"The menulist should have a tooltip text attributed.");
closeDebuggerAndFinish();
});
});
});
content.location = EXAMPLE_URL + "browser_dbg_iframes.html";
});
}
registerCleanupFunction(function() {
removeTab(gTab);
gPane = null;
gTab = null;
gDebuggee = null;
gDebugger = null;
});

View File

@ -191,6 +191,11 @@ function clear() {
function write(text) { function write(text) {
clear(); clear();
append(text);
}
function append(text) {
gSearchBox.focus();
for (let i = 0; i < text.length; i++) { for (let i = 0; i < text.length; i++) {
EventUtils.sendChar(text[i]); EventUtils.sendChar(text[i]);

View File

@ -96,6 +96,8 @@ function secondSearch() {
window.removeEventListener(aEvent.type, _onEvent); window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() { executeSoon(function() {
append("#" + token);
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n"); info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
ok(gEditor.getCaretPosition().line == 5 && ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length, gEditor.getCaretPosition().col == 8 + token.length,
@ -103,6 +105,49 @@ function secondSearch() {
is(gScripts.visibleItemsCount, 1, is(gScripts.visibleItemsCount, 1,
"Not all the correct scripts are shown after the search. (2)"); "Not all the correct scripts are shown after the search. (2)");
waitForFirstScript();
});
}
});
gScripts.selectIndex(1);
}
function waitForFirstScript() {
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
info("Current script url:\n" + aEvent.detail.url + "\n");
info("Debugger editor text:\n" + gEditor.getText() + "\n");
let url = aEvent.detail.url;
if (url.indexOf("-01.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() {
thirdSearch();
});
}
});
gScripts.selectIndex(0);
}
function thirdSearch() {
let token = "deb";
window.addEventListener("Debugger:ScriptShown", function _onEvent(aEvent) {
info("Current script url:\n" + aEvent.detail.url + "\n");
info("Debugger editor text:\n" + gEditor.getText() + "\n");
let url = aEvent.detail.url;
if (url.indexOf("-02.js") != -1) {
window.removeEventListener(aEvent.type, _onEvent);
executeSoon(function() {
info("Editor caret position: " + gEditor.getCaretPosition().toSource() + "\n");
ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length,
"The editor didn't jump to the correct line. (3)");
is(gScripts.visibleItemsCount, 1,
"Not all the correct scripts are shown after the search. (3)");
finalCheck(0, "ugger;", token); finalCheck(0, "ugger;", token);
}); });
} }
@ -115,7 +160,7 @@ function finalCheck(i, string, token) {
ok(gEditor.getCaretPosition().line == 5 && ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i, gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (3)"); "The editor didn't remain at the correct token. (4)");
if (string[i]) { if (string[i]) {
EventUtils.sendChar(string[i]); EventUtils.sendChar(string[i]);
@ -126,7 +171,7 @@ function finalCheck(i, string, token) {
clear(); clear();
ok(gEditor.getCaretPosition().line == 5 && ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i, gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (4)"); "The editor didn't remain at the correct token. (5)");
executeSoon(function() { executeSoon(function() {
let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText"); let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText");
@ -139,7 +184,7 @@ function finalCheck(i, string, token) {
write("BOGUS"); write("BOGUS");
ok(gEditor.getCaretPosition().line == 5 && ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i, gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (5)"); "The editor didn't remain at the correct token. (6)");
is(gMenulist.getAttribute("label"), noMatchingScripts, is(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should display a notice that no scripts match the searched token."); "The menulist should display a notice that no scripts match the searched token.");
@ -151,7 +196,7 @@ function finalCheck(i, string, token) {
clear(); clear();
ok(gEditor.getCaretPosition().line == 5 && ok(gEditor.getCaretPosition().line == 5 &&
gEditor.getCaretPosition().col == 8 + token.length + i, gEditor.getCaretPosition().col == 8 + token.length + i,
"The editor didn't remain at the correct token. (6)"); "The editor didn't remain at the correct token. (7)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts, isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice after the searchbox was emptied."); "The menulist should not display a notice after the searchbox was emptied.");
@ -171,6 +216,11 @@ function clear() {
function write(text) { function write(text) {
clear(); clear();
append(text);
}
function append(text) {
gSearchBox.focus();
for (let i = 0; i < text.length; i++) { for (let i = 0; i < text.length; i++) {
EventUtils.sendChar(text[i]); EventUtils.sendChar(text[i]);

View File

@ -550,7 +550,7 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
this._loadCallback = aLoadCallback; this._loadCallback = aLoadCallback;
/* /*
<panel id="gcli-output" <tooltip id="gcli-output"
noautofocus="true" noautofocus="true"
noautohide="true" noautohide="true"
class="gcli-panel"> class="gcli-panel">
@ -558,13 +558,15 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
id="gcli-output-frame" id="gcli-output-frame"
src="chrome://browser/content/devtools/gclioutput.xhtml" src="chrome://browser/content/devtools/gclioutput.xhtml"
flex="1"/> flex="1"/>
</panel> </tooltip>
*/ */
this._panel = aChromeDoc.createElement("panel");
// TODO: Switch back from tooltip to panel when metacity focus issue is fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
this._panel = aChromeDoc.createElement("tooltip");
this._panel.id = "gcli-output"; this._panel.id = "gcli-output";
this._panel.classList.add("gcli-panel"); this._panel.classList.add("gcli-panel");
this._panel.setAttribute("noautofocus", "true");
this._panel.setAttribute("noautohide", "true");
this._toolbar.parentElement.insertBefore(this._panel, this._toolbar); this._toolbar.parentElement.insertBefore(this._panel, this._toolbar);
this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe"); this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe");
@ -579,6 +581,10 @@ function OutputPanel(aChromeDoc, aInput, aLoadCallback)
this._frame.addEventListener("load", this._onload, true); this._frame.addEventListener("load", this._onload, true);
this.loaded = false; this.loaded = false;
this.canHide = false;
this._onpopuphiding = this._onpopuphiding.bind(this);
this._panel.addEventListener("popuphiding", this._onpopuphiding, true);
} }
/** /**
@ -606,6 +612,18 @@ OutputPanel.prototype._onload = function OP_onload()
} }
}; };
/**
* Prevent the popup from hiding if it is not permitted via this.canHide.
*/
OutputPanel.prototype._onpopuphiding = function OP_onpopuphiding(aEvent)
{
// TODO: When we switch back from tooltip to panel we can remove this hack:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
if (!this.canHide) {
aEvent.preventDefault();
}
};
/** /**
* Display the OutputPanel. * Display the OutputPanel.
*/ */
@ -618,6 +636,8 @@ OutputPanel.prototype.show = function OP_show()
this._resize(); this._resize();
}.bind(this), 0); }.bind(this), 0);
this.canHide = false;
this._panel.openPopup(this._input, "before_start", 0, 0, false, false, null); this._panel.openPopup(this._input, "before_start", 0, 0, false, false, null);
this._resize(); this._resize();
@ -677,6 +697,7 @@ OutputPanel.prototype.update = function OP_update()
*/ */
OutputPanel.prototype.remove = function OP_remove() OutputPanel.prototype.remove = function OP_remove()
{ {
this.canHide = true;
this._panel.hidePopup(); this._panel.hidePopup();
if (this.displayedOutput) { if (this.displayedOutput) {
@ -693,11 +714,15 @@ OutputPanel.prototype.destroy = function OP_destroy()
{ {
this.remove(); this.remove();
this._panel.removeEventListener("popuphiding", this._onpopuphiding, true);
this._panel.removeChild(this._frame); this._panel.removeChild(this._frame);
this._toolbar.parentElement.removeChild(this._panel); this._toolbar.parentElement.removeChild(this._panel);
delete this._input; delete this._input;
delete this._toolbar; delete this._toolbar;
delete this._onload;
delete this._onpopuphiding;
delete this._panel; delete this._panel;
delete this._frame; delete this._frame;
delete this._content; delete this._content;
@ -714,6 +739,7 @@ OutputPanel.prototype._visibilityChanged = function OP_visibilityChanged(aEvent)
if (aEvent.outputVisible === true) { if (aEvent.outputVisible === true) {
// this.show is called by _outputChanged // this.show is called by _outputChanged
} else { } else {
this.canHide = true;
this._panel.hidePopup(); this._panel.hidePopup();
} }
}; };
@ -734,7 +760,7 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
this._onload = this._onload.bind(this); this._onload = this._onload.bind(this);
this._loadCallback = aLoadCallback; this._loadCallback = aLoadCallback;
/* /*
<panel id="gcli-tooltip" <tooltip id="gcli-tooltip"
type="arrow" type="arrow"
noautofocus="true" noautofocus="true"
noautohide="true" noautohide="true"
@ -743,13 +769,15 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
id="gcli-tooltip-frame" id="gcli-tooltip-frame"
src="chrome://browser/content/devtools/gclitooltip.xhtml" src="chrome://browser/content/devtools/gclitooltip.xhtml"
flex="1"/> flex="1"/>
</panel> </tooltip>
*/ */
this._panel = aChromeDoc.createElement("panel");
// TODO: Switch back from tooltip to panel when metacity focus issue is fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
this._panel = aChromeDoc.createElement("tooltip");
this._panel.id = "gcli-tooltip"; this._panel.id = "gcli-tooltip";
this._panel.classList.add("gcli-panel"); this._panel.classList.add("gcli-panel");
this._panel.setAttribute("noautofocus", "true");
this._panel.setAttribute("noautohide", "true");
this._toolbar.parentElement.insertBefore(this._panel, this._toolbar); this._toolbar.parentElement.insertBefore(this._panel, this._toolbar);
this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe"); this._frame = aChromeDoc.createElementNS(NS_XHTML, "iframe");
@ -759,7 +787,12 @@ function TooltipPanel(aChromeDoc, aInput, aLoadCallback)
this._panel.appendChild(this._frame); this._panel.appendChild(this._frame);
this._frame.addEventListener("load", this._onload, true); this._frame.addEventListener("load", this._onload, true);
this.loaded = false; this.loaded = false;
this.canHide = false;
this._onpopuphiding = this._onpopuphiding.bind(this);
this._panel.addEventListener("popuphiding", this._onpopuphiding, true);
} }
/** /**
@ -785,6 +818,18 @@ TooltipPanel.prototype._onload = function TP_onload()
} }
}; };
/**
* Prevent the popup from hiding if it is not permitted via this.canHide.
*/
TooltipPanel.prototype._onpopuphiding = function TP_onpopuphiding(aEvent)
{
// TODO: When we switch back from tooltip to panel we can remove this hack:
// https://bugzilla.mozilla.org/show_bug.cgi?id=780102
if (!this.canHide) {
aEvent.preventDefault();
}
};
/** /**
* Display the TooltipPanel. * Display the TooltipPanel.
*/ */
@ -802,6 +847,8 @@ TooltipPanel.prototype.show = function TP_show(aDimensions)
this._resize(); this._resize();
}.bind(this), 0); }.bind(this), 0);
this.canHide = false;
this._resize(); this._resize();
this._panel.openPopup(this._input, "before_start", aDimensions.start * 10, 0, false, false, null); this._panel.openPopup(this._input, "before_start", aDimensions.start * 10, 0, false, false, null);
this._input.focus(); this._input.focus();
@ -845,6 +892,7 @@ TooltipPanel.prototype._resize = function TP_resize()
*/ */
TooltipPanel.prototype.remove = function TP_remove() TooltipPanel.prototype.remove = function TP_remove()
{ {
this.canHide = true;
this._panel.hidePopup(); this._panel.hidePopup();
}; };
@ -855,6 +903,8 @@ TooltipPanel.prototype.destroy = function TP_destroy()
{ {
this.remove(); this.remove();
this._panel.removeEventListener("popuphiding", this._onpopuphiding, true);
this._panel.removeChild(this._frame); this._panel.removeChild(this._frame);
this._toolbar.parentElement.removeChild(this._panel); this._toolbar.parentElement.removeChild(this._panel);
@ -862,6 +912,7 @@ TooltipPanel.prototype.destroy = function TP_destroy()
delete this._dimensions; delete this._dimensions;
delete this._input; delete this._input;
delete this._onload; delete this._onload;
delete this._onpopuphiding;
delete this._panel; delete this._panel;
delete this._frame; delete this._frame;
delete this._toolbar; delete this._toolbar;
@ -879,6 +930,7 @@ TooltipPanel.prototype._visibilityChanged = function TP_visibilityChanged(aEvent
if (aEvent.tooltipVisible === true) { if (aEvent.tooltipVisible === true) {
this.show(aEvent.dimensions); this.show(aEvent.dimensions);
} else { } else {
this.canHide = true;
this._panel.hidePopup(); this._panel.hidePopup();
} }
}; };

View File

@ -18,11 +18,13 @@ let webappsUI = {
init: function webappsUI_init() { init: function webappsUI_init() {
Services.obs.addObserver(this, "webapps-ask-install", false); Services.obs.addObserver(this, "webapps-ask-install", false);
Services.obs.addObserver(this, "webapps-launch", false); Services.obs.addObserver(this, "webapps-launch", false);
Services.obs.addObserver(this, "webapps-uninstall", false);
}, },
uninit: function webappsUI_uninit() { uninit: function webappsUI_uninit() {
Services.obs.removeObserver(this, "webapps-ask-install"); Services.obs.removeObserver(this, "webapps-ask-install");
Services.obs.removeObserver(this, "webapps-launch"); Services.obs.removeObserver(this, "webapps-launch");
Services.obs.removeObserver(this, "webapps-uninstall");
}, },
observe: function webappsUI_observe(aSubject, aTopic, aData) { observe: function webappsUI_observe(aSubject, aTopic, aData) {
@ -37,6 +39,9 @@ let webappsUI = {
case "webapps-launch": case "webapps-launch":
WebappOSUtils.launch(data); WebappOSUtils.launch(data);
break; break;
case "webapps-uninstall":
WebappOSUtils.uninstall(data);
break;
} }
}, },

View File

@ -3311,6 +3311,7 @@ stack[anonid=browserStack][responsivemode] {
text-shadow: none; text-shadow: none;
background-image: -moz-linear-gradient(top, #B4211B, #8A1915); background-image: -moz-linear-gradient(top, #B4211B, #8A1915);
border-radius: 1px; border-radius: 1px;
-moz-margin-end: 5px;
} }

View File

@ -18,8 +18,8 @@ from devicemanager import DeviceManager, NetworkTools
from mozprocess import ProcessHandlerMixin from mozprocess import ProcessHandlerMixin
class LogcatProc(ProcessHandlerMixin): class StdOutProc(ProcessHandlerMixin):
"""Process handler for logcat which puts all output in a Queue. """Process handler for b2g which puts all output in a Queue.
""" """
def __init__(self, cmd, queue, **kwargs): def __init__(self, cmd, queue, **kwargs):
@ -76,6 +76,20 @@ class B2GRemoteAutomation(Automation):
env['MOZ_HIDE_RESULTS_TABLE'] = '1' env['MOZ_HIDE_RESULTS_TABLE'] = '1'
return env return env
def waitForNet(self):
active = False
time_out = 0
while not active and time_out < 40:
data = self._devicemanager.runCmd(['shell', '/system/bin/netcfg']).stdout.readlines()
data.pop(0)
for line in data:
if (re.search(r'UP\s+(?:[0-9]{1,3}\.){3}[0-9]{1,3}', line)):
active = True
break
time_out += 1
time.sleep(1)
return active
def checkForCrashes(self, directory, symbolsPath): def checkForCrashes(self, directory, symbolsPath):
# XXX: This will have to be updated after crash reporting on b2g # XXX: This will have to be updated after crash reporting on b2g
# is in place. # is in place.
@ -160,7 +174,11 @@ class B2GRemoteAutomation(Automation):
serial, status = self.getDeviceStatus() serial, status = self.getDeviceStatus()
# reboot! # reboot!
self._devicemanager.checkCmd(['reboot']) self._devicemanager.runCmd(['shell', '/system/bin/reboot'])
# The above command can return while adb still thinks the device is
# connected, so wait a little bit for it to disconnect from adb.
time.sleep(10)
# wait for device to come back to previous status # wait for device to come back to previous status
print 'waiting for device to come back online after reboot' print 'waiting for device to come back online after reboot'
@ -183,21 +201,26 @@ class B2GRemoteAutomation(Automation):
# to pass env variables into the B2G process, but this doesn't # to pass env variables into the B2G process, but this doesn't
# seem to matter. # seem to matter.
instance = self.B2GInstance(self._devicemanager)
# reboot device so it starts up with the mochitest profile # reboot device so it starts up with the mochitest profile
# XXX: We could potentially use 'stop b2g' + 'start b2g' to achieve # XXX: We could potentially use 'stop b2g' + 'start b2g' to achieve
# a similar effect; will see which is more stable while attempting # a similar effect; will see which is more stable while attempting
# to bring up the continuous integration. # to bring up the continuous integration.
if self._is_emulator: if not self._is_emulator:
self.restartB2G()
else:
self.rebootDevice() self.rebootDevice()
time.sleep(5)
#wait for wlan to come up
if not self.waitForNet():
raise Exception("network did not come up, please configure the network" +
" prior to running before running the automation framework")
# Infrequently, gecko comes up before networking does, so wait a little # stop b2g
# bit to give the network time to become available. self._devicemanager.runCmd(['shell', 'stop', 'b2g'])
# XXX: need a more robust mechanism for this time.sleep(5)
time.sleep(40)
# relaunch b2g inside b2g instance
instance = self.B2GInstance(self._devicemanager)
time.sleep(5)
# Set up port forwarding again for Marionette, since any that # Set up port forwarding again for Marionette, since any that
# existed previously got wiped out by the reboot. # existed previously got wiped out by the reboot.
@ -206,6 +229,11 @@ class B2GRemoteAutomation(Automation):
'tcp:%s' % self.marionette.port, 'tcp:%s' % self.marionette.port,
'tcp:%s' % self.marionette.port]) 'tcp:%s' % self.marionette.port])
if self._is_emulator:
self.marionette.emulator.wait_for_port()
else:
time.sleep(5)
# start a marionette session # start a marionette session
session = self.marionette.start_session() session = self.marionette.start_session()
if 'b2g' not in session: if 'b2g' not in session:
@ -228,26 +256,29 @@ class B2GRemoteAutomation(Automation):
def __init__(self, dm): def __init__(self, dm):
self.dm = dm self.dm = dm
self.logcat_proc = None self.stdout_proc = None
self.queue = Queue.Queue() self.queue = Queue.Queue()
# Launch logcat in a separate thread, and dump all output lines # Launch b2g in a separate thread, and dump all output lines
# into a queue. The lines in this queue are # into a queue. The lines in this queue are
# retrieved and returned by accessing the stdout property of # retrieved and returned by accessing the stdout property of
# this class. # this class.
cmd = [self.dm.adbPath] cmd = [self.dm.adbPath]
if self.dm.deviceSerial: if self.dm.deviceSerial:
cmd.extend(['-s', self.dm.deviceSerial]) cmd.extend(['-s', self.dm.deviceSerial])
cmd.append('logcat') cmd.append('shell')
proc = threading.Thread(target=self._save_logcat_proc, args=(cmd, self.queue)) cmd.append('/system/bin/b2g.sh')
proc = threading.Thread(target=self._save_stdout_proc, args=(cmd, self.queue))
proc.daemon = True proc.daemon = True
proc.start() proc.start()
def _save_logcat_proc(self, cmd, queue): def _save_stdout_proc(self, cmd, queue):
self.logcat_proc = LogcatProc(cmd, queue) self.stdout_proc = StdOutProc(cmd, queue)
self.logcat_proc.run() self.stdout_proc.run()
self.logcat_proc.waitForFinish() if hasattr(self.stdout_proc, 'processOutput'):
self.logcat_proc = None self.stdout_proc.processOutput()
self.stdout_proc.waitForFinish()
self.stdout_proc = None
@property @property
def pid(self): def pid(self):
@ -257,7 +288,7 @@ class B2GRemoteAutomation(Automation):
@property @property
def stdout(self): def stdout(self):
# Return any lines in the queue used by the # Return any lines in the queue used by the
# logcat process handler. # b2g process handler.
lines = [] lines = []
while True: while True:
try: try:

View File

@ -21,7 +21,7 @@ interface nsIContentSecurityPolicy;
[ptr] native JSPrincipals(JSPrincipals); [ptr] native JSPrincipals(JSPrincipals);
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >); [ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);
[scriptable, uuid(8a74b011-667d-4cfa-b2a2-b27582ba5f38)] [scriptable, uuid(6df7d16d-5b26-42a1-b1f7-069d46c37aa8)]
interface nsIPrincipal : nsISerializable interface nsIPrincipal : nsISerializable
{ {
/** /**
@ -230,13 +230,13 @@ interface nsIPrincipal : nsISerializable
const short APP_STATUS_NOT_INSTALLED = 0; const short APP_STATUS_NOT_INSTALLED = 0;
const short APP_STATUS_INSTALLED = 1; const short APP_STATUS_INSTALLED = 1;
const short APP_STATUS_TRUSTED = 2; const short APP_STATUS_PRIVILEGED = 2;
const short APP_STATUS_CERTIFIED = 3; const short APP_STATUS_CERTIFIED = 3;
/** /**
* Shows the status of the app. * Shows the status of the app.
* Can be: APP_STATUS_NOT_INSTALLED, APP_STATUS_INSTALLED, * Can be: APP_STATUS_NOT_INSTALLED, APP_STATUS_INSTALLED,
* APP_STATUS_TRUSTED or APP_STATUS_CERTIFIED. * APP_STATUS_PRIVILEGED or APP_STATUS_CERTIFIED.
*/ */
readonly attribute unsigned short appStatus; readonly attribute unsigned short appStatus;

View File

@ -1043,7 +1043,7 @@ nsPrincipal::InitFromPersistent(const char* aPrefName,
const char* ordinalBegin = PL_strpbrk(aPrefName, "1234567890"); const char* ordinalBegin = PL_strpbrk(aPrefName, "1234567890");
if (ordinalBegin) { if (ordinalBegin) {
PRIntn n = atoi(ordinalBegin); int n = atoi(ordinalBegin);
if (sCapabilitiesOrdinal <= n) { if (sCapabilitiesOrdinal <= n) {
sCapabilitiesOrdinal = n + 1; sCapabilitiesOrdinal = n + 1;
} }
@ -1122,7 +1122,7 @@ nsPrincipal::Read(nsIObjectInputStream* aStream)
const char* ordinalBegin = PL_strpbrk(mPrefName.get(), "1234567890"); const char* ordinalBegin = PL_strpbrk(mPrefName.get(), "1234567890");
if (ordinalBegin) { if (ordinalBegin) {
PRIntn n = atoi(ordinalBegin); int n = atoi(ordinalBegin);
if (sCapabilitiesOrdinal <= n) { if (sCapabilitiesOrdinal <= n) {
sCapabilitiesOrdinal = n + 1; sCapabilitiesOrdinal = n + 1;
} }

View File

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DirectionalityUtils_h___
#define DirectionalityUtils_h___
class nsIContent;
class nsIDocument;
class nsINode;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace directionality {
enum Directionality {
eDir_NotSet = 0,
eDir_RTL = 1,
eDir_LTR = 2
};
void SetDirectionality(mozilla::dom::Element* aElement, Directionality aDir,
bool aNotify = true);
/**
* Set the directionality of an element according to the algorithm defined at
* http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-directionality,
* not including elements with auto direction.
*
* @return the directionality that the element was set to
*/
Directionality RecomputeDirectionality(mozilla::dom::Element* aElement,
bool aNotify = true);
/**
* Set the directionality of any descendants of a node that do not themselves
* have a dir attribute.
* For performance reasons we walk down the descendant tree in the rare case
* of setting the dir attribute, rather than walking up the ancestor tree in
* the much more common case of getting the element's directionality.
*/
void SetDirectionalityOnDescendants(mozilla::dom::Element* aElement,
Directionality aDir,
bool aNotify = true);
} // end namespace directionality
} // end namespace mozilla
#endif /* DirectionalityUtils_h___ */

View File

@ -10,7 +10,6 @@
#include "mozilla/dom/FragmentOrElement.h" // for base class #include "mozilla/dom/FragmentOrElement.h" // for base class
#include "nsChangeHint.h" // for enum #include "nsChangeHint.h" // for enum
#include "nsEventStates.h" // for member #include "nsEventStates.h" // for member
#include "mozilla/dom/DirectionalityUtils.h"
class nsEventStateManager; class nsEventStateManager;
class nsFocusManager; class nsFocusManager;
@ -217,18 +216,6 @@ public:
*/ */
virtual nsIAtom *GetClassAttributeName() const = 0; virtual nsIAtom *GetClassAttributeName() const = 0;
inline mozilla::directionality::Directionality GetDirectionality() const {
if (HasFlag(NODE_HAS_DIRECTION_RTL)) {
return mozilla::directionality::eDir_RTL;
}
if (HasFlag(NODE_HAS_DIRECTION_LTR)) {
return mozilla::directionality::eDir_LTR;
}
return mozilla::directionality::eDir_NotSet;
}
protected: protected:
/** /**
* Method to get the _intrinsic_ content state of this element. This is the * Method to get the _intrinsic_ content state of this element. This is the

View File

@ -48,7 +48,6 @@ $(NULL)
EXPORTS_NAMESPACES = mozilla/dom mozilla EXPORTS_NAMESPACES = mozilla/dom mozilla
EXPORTS_mozilla/dom = \ EXPORTS_mozilla/dom = \
DirectionalityUtils.h \
Element.h \ Element.h \
FragmentOrElement.h \ FragmentOrElement.h \
FromParser.h \ FromParser.h \

View File

@ -23,7 +23,6 @@
#include "nsPIDOMWindow.h" // for use in inline functions #include "nsPIDOMWindow.h" // for use in inline functions
#include "nsPropertyTable.h" // for member #include "nsPropertyTable.h" // for member
#include "nsTHashtable.h" // for member #include "nsTHashtable.h" // for member
#include "mozilla/dom/DirectionalityUtils.h"
class imgIRequest; class imgIRequest;
class nsAString; class nsAString;
@ -398,10 +397,6 @@ public:
{ {
mBidiOptions = aBidiOptions; mBidiOptions = aBidiOptions;
} }
inline mozilla::directionality::Directionality GetDocumentDirectionality() {
return mDirectionality;
}
/** /**
* Access HTTP header data (this may also get set from other * Access HTTP header data (this may also get set from other
@ -1858,9 +1853,6 @@ protected:
// defined in nsBidiUtils.h // defined in nsBidiUtils.h
PRUint32 mBidiOptions; PRUint32 mBidiOptions;
// The root directionality of this document.
mozilla::directionality::Directionality mDirectionality;
nsCString mContentLanguage; nsCString mContentLanguage;
private: private:
nsCString mContentType; nsCString mContentType;

View File

@ -145,16 +145,8 @@ enum {
// Set if the node has had :hover selectors matched against it // Set if the node has had :hover selectors matched against it
NODE_HAS_RELEVANT_HOVER_RULES = 0x00080000U, NODE_HAS_RELEVANT_HOVER_RULES = 0x00080000U,
// Set if the node has right-to-left directionality
NODE_HAS_DIRECTION_RTL = 0x00100000U,
// Set if the node has left-to-right directionality
NODE_HAS_DIRECTION_LTR = 0x00200000U,
NODE_ALL_DIRECTION_FLAGS = NODE_HAS_DIRECTION_LTR | NODE_HAS_DIRECTION_RTL,
// Remaining bits are node type specific. // Remaining bits are node type specific.
NODE_TYPE_SPECIFIC_BITS_OFFSET = 22 NODE_TYPE_SPECIFIC_BITS_OFFSET = 20
}; };
/** /**
@ -1287,8 +1279,6 @@ private:
NodeIsContent, NodeIsContent,
// Set if the node has animations or transitions // Set if the node has animations or transitions
ElementHasAnimations, ElementHasAnimations,
// Set if node has a dir attribute with a valid value (ltr or rtl)
NodeHasValidDirAttribute,
// Guard value // Guard value
BooleanFlagCount BooleanFlagCount
}; };
@ -1356,9 +1346,6 @@ public:
void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); } void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); }
bool MayHaveAnimations() { return GetBoolFlag(ElementHasAnimations); } bool MayHaveAnimations() { return GetBoolFlag(ElementHasAnimations); }
void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); } void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); }
void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); }
void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); }
bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); }
protected: protected:
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); } void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
void SetInDocument() { SetBoolFlag(IsInDocument); } void SetInDocument() { SetBoolFlag(IsInDocument); }

View File

@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=78: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsINode.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMNodeFilter.h"
#include "nsTreeWalker.h"
#include "nsIDOMHTMLDocument.h"
namespace mozilla {
namespace directionality {
typedef mozilla::dom::Element Element;
void
SetDirectionality(Element* aElement, Directionality aDir, bool aNotify)
{
aElement->UnsetFlags(NODE_ALL_DIRECTION_FLAGS);
switch (aDir) {
case eDir_RTL:
aElement->SetFlags(NODE_HAS_DIRECTION_RTL);
break;
case eDir_LTR:
aElement->SetFlags(NODE_HAS_DIRECTION_LTR);
break;
default:
break;
}
aElement->UpdateState(aNotify);
}
Directionality
RecomputeDirectionality(Element* aElement, bool aNotify)
{
Directionality dir = eDir_LTR;
if (aElement->HasValidDir()) {
dir = aElement->GetDirectionality();
} else {
Element* parent = aElement->GetElementParent();
if (parent) {
// If the element doesn't have an explicit dir attribute with a valid
// value, the directionality is the same as the parent element (but
// don't propagate the parent directionality if it isn't set yet).
Directionality parentDir = parent->GetDirectionality();
if (parentDir != eDir_NotSet) {
dir = parentDir;
}
} else {
// If there is no parent element, the directionality is the same as the
// document direction.
Directionality documentDir =
aElement->OwnerDoc()->GetDocumentDirectionality();
if (documentDir != eDir_NotSet) {
dir = documentDir;
}
}
SetDirectionality(aElement, dir, aNotify);
}
return dir;
}
void
SetDirectionalityOnDescendants(Element* aElement, Directionality aDir,
bool aNotify)
{
for (nsIContent* child = aElement->GetFirstChild(); child; ) {
if (!child->IsElement()) {
child = child->GetNextNode(aElement);
continue;
}
Element* element = child->AsElement();
if (element->HasValidDir()) {
child = child->GetNextNonChildNode(aElement);
continue;
}
SetDirectionality(element, aDir, aNotify);
child = child->GetNextNode(aElement);
}
}
} // end namespace directionality
} // end namespace mozilla

View File

@ -53,7 +53,6 @@ LOCAL_INCLUDES = \
$(NULL) $(NULL)
CPPSRCS = \ CPPSRCS = \
DirectionalityUtils.cpp \
nsAtomListUtils.cpp \ nsAtomListUtils.cpp \
nsAttrAndChildArray.cpp \ nsAttrAndChildArray.cpp \
nsAttrValue.cpp \ nsAttrValue.cpp \

View File

@ -53,7 +53,7 @@ extern PRLogModuleInfo* gContentSinkLogModuleInfo;
#define SINK_TRACE_REFLOW 0x2 #define SINK_TRACE_REFLOW 0x2
#define SINK_ALWAYS_REFLOW 0x4 #define SINK_ALWAYS_REFLOW 0x4
#define SINK_LOG_TEST(_lm, _bit) (PRIntn((_lm)->level) & (_bit)) #define SINK_LOG_TEST(_lm, _bit) (int((_lm)->level) & (_bit))
#define SINK_TRACE(_lm, _bit, _args) \ #define SINK_TRACE(_lm, _bit, _args) \
PR_BEGIN_MACRO \ PR_BEGIN_MACRO \

View File

@ -91,7 +91,6 @@
#include "nsXMLEventsManager.h" #include "nsXMLEventsManager.h"
#include "nsBidiUtils.h" #include "nsBidiUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsIDOMUserDataHandler.h" #include "nsIDOMUserDataHandler.h"
#include "nsIDOMXPathEvaluator.h" #include "nsIDOMXPathEvaluator.h"
@ -171,7 +170,6 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::directionality;
typedef nsTArray<Link*> LinkArray; typedef nsTArray<Link*> LinkArray;
@ -1512,8 +1510,7 @@ nsIDocument::nsIDocument()
mAllowDNSPrefetch(true), mAllowDNSPrefetch(true),
mIsBeingUsedAsImage(false), mIsBeingUsedAsImage(false),
mHasLinksToUpdate(false), mHasLinksToUpdate(false),
mPartID(0), mPartID(0)
mDirectionality(eDir_LTR)
{ {
SetInDocument(); SetInDocument();
} }
@ -5586,15 +5583,6 @@ nsDocument::SetDir(const nsAString& aDirection)
// No presentation; just set it on ourselves // No presentation; just set it on ourselves
SetBidiOptions(options); SetBidiOptions(options);
} }
Directionality dir = elt->mValue == IBMBIDI_TEXTDIRECTION_RTL ?
eDir_RTL : eDir_LTR;
SetDocumentDirectionality(dir);
// Set the directionality of the root element and its descendants, if any
Element* rootElement = GetRootElement();
if (rootElement) {
SetDirectionality(rootElement, dir, true);
SetDirectionalityOnDescendants(rootElement, dir);
}
} }
break; break;

View File

@ -1048,12 +1048,6 @@ protected:
nsIContent* GetFirstBaseNodeWithHref(); nsIContent* GetFirstBaseNodeWithHref();
nsresult SetFirstBaseNodeWithHref(nsIContent *node); nsresult SetFirstBaseNodeWithHref(nsIContent *node);
inline void
SetDocumentDirectionality(mozilla::directionality::Directionality aDir)
{
mDirectionality = aDir;
}
// Get the first <title> element with the given IsNodeOfType type, or // Get the first <title> element with the given IsNodeOfType type, or
// return null if there isn't one // return null if there isn't one
nsIContent* GetTitleContent(PRUint32 aNodeType); nsIContent* GetTitleContent(PRUint32 aNodeType);

View File

@ -13,6 +13,7 @@
#include "prenv.h" #include "prenv.h"
#include "mozIApplication.h"
#include "nsIDOMHTMLIFrameElement.h" #include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMMozBrowserFrame.h" #include "nsIDOMMozBrowserFrame.h"
@ -31,6 +32,7 @@
#include "nsIDocShellTreeNode.h" #include "nsIDocShellTreeNode.h"
#include "nsIDocShellTreeOwner.h" #include "nsIDocShellTreeOwner.h"
#include "nsIDocShellLoadInfo.h" #include "nsIDocShellLoadInfo.h"
#include "nsIDOMApplicationRegistry.h"
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIXPConnect.h" #include "nsIXPConnect.h"
@ -1973,9 +1975,8 @@ nsFrameLoader::TryRemoteBrowser()
return false; return false;
} }
PRUint32 appId = 0;
bool isBrowserElement = false; bool isBrowserElement = false;
nsCOMPtr<mozIApplication> app;
if (OwnerIsBrowserFrame()) { if (OwnerIsBrowserFrame()) {
isBrowserElement = true; isBrowserElement = true;
@ -1989,24 +1990,21 @@ nsFrameLoader::TryRemoteBrowser()
return false; return false;
} }
appsService->GetAppLocalIdByManifestURL(manifest, &appId); nsCOMPtr<mozIDOMApplication> domApp;
appsService->GetAppByManifestURL(manifest, getter_AddRefs(domApp));
// If the frame is actually an app, we should not mark it as a browser. // If the frame is actually an app, we should not mark it as a
if (appId != nsIScriptSecurityManager::NO_APP_ID) { // browser. This is to identify the data store: since <app>s
// and <browser>s-within-<app>s have different stores, we want
// to ensure the <app> uses its store, not the one for its
// <browser>s.
app = do_QueryInterface(domApp);
if (app) {
isBrowserElement = false; isBrowserElement = false;
} }
} }
} }
// If our owner has no app manifest URL, then this is equivalent to if ((mRemoteBrowser = ContentParent::CreateBrowser(app, isBrowserElement))) {
// ContentParent::GetNewOrUsed().
nsAutoString appManifest;
GetOwnerAppManifestURL(appManifest);
ContentParent* parent = ContentParent::GetForApp(appManifest);
NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!");
mRemoteBrowser = parent->CreateTab(chromeFlags, isBrowserElement, appId);
if (mRemoteBrowser) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent); nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
mRemoteBrowser->SetOwnerElement(element); mRemoteBrowser->SetOwnerElement(element);
@ -2019,8 +2017,8 @@ nsFrameLoader::TryRemoteBrowser()
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin; nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin)); rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin); mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin);
mChildHost = parent; mChildHost = static_cast<ContentParent*>(mRemoteBrowser->Manager());
} }
return true; return true;
} }

View File

@ -51,7 +51,6 @@
#include "nsIDOMMutationEvent.h" #include "nsIDOMMutationEvent.h"
#include "nsMutationEvent.h" #include "nsMutationEvent.h"
#include "nsNodeUtils.h" #include "nsNodeUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsDocument.h" #include "nsDocument.h"
#include "nsAttrValueOrString.h" #include "nsAttrValueOrString.h"
#ifdef MOZ_XUL #ifdef MOZ_XUL
@ -129,7 +128,6 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::directionality;
nsEventStates nsEventStates
Element::IntrinsicState() const Element::IntrinsicState() const
@ -1360,13 +1358,6 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
SetSubtreeRootPointer(aParent->SubtreeRoot()); SetSubtreeRootPointer(aParent->SubtreeRoot());
} }
// This has to be here, rather than in nsGenericHTMLElement::BindToTree,
// because it has to happen after updating the parent pointer, but before
// recursively binding the kids.
if (IsHTML()) {
RecomputeDirectionality(this, false);
}
// If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children // If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children
// that also need to be told that they are moving. // that also need to be told that they are moving.
nsresult rv; nsresult rv;
@ -1552,13 +1543,6 @@ nsGenericElement::UnbindFromTree(bool aDeep, bool aNullParent)
} }
} }
// This has to be here, rather than in nsGenericHTMLElement::UnbindFromTree,
// because it has to happen after unsetting the parent pointer, but before
// recursively unbinding the kids.
if (IsHTML()) {
RecomputeDirectionality(this, false);
}
if (aDeep) { if (aDeep) {
// Do the kids. Don't call GetChildCount() here since that'll force // Do the kids. Don't call GetChildCount() here since that'll force
// XUL to generate template children, which there is no need for since // XUL to generate template children, which there is no need for since

View File

@ -270,7 +270,6 @@ GK_ATOM(dialog, "dialog")
GK_ATOM(difference, "difference") GK_ATOM(difference, "difference")
GK_ATOM(digit, "digit") GK_ATOM(digit, "digit")
GK_ATOM(dir, "dir") GK_ATOM(dir, "dir")
GK_ATOM(directionality, "directionality")
GK_ATOM(disableOutputEscaping, "disable-output-escaping") GK_ATOM(disableOutputEscaping, "disable-output-escaping")
GK_ATOM(disabled, "disabled") GK_ATOM(disabled, "disabled")
GK_ATOM(display, "display") GK_ATOM(display, "display")

View File

@ -54,7 +54,7 @@ nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
} }
PRIntn int
nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2) nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2)
{ {
NS_ASSERTION(key1 && key2, "Null key passed to NodeInfoInnerKeyCompare!"); NS_ASSERTION(key1 && key2, "Null key passed to NodeInfoInnerKeyCompare!");
@ -183,8 +183,8 @@ nsNodeInfoManager::Init(nsIDocument *aDocument)
} }
// static // static
PRIntn int
nsNodeInfoManager::DropNodeInfoDocument(PLHashEntry *he, PRIntn hashIndex, void *arg) nsNodeInfoManager::DropNodeInfoDocument(PLHashEntry *he, int hashIndex, void *arg)
{ {
static_cast<nsINodeInfo*>(he->value)->mDocument = nullptr; static_cast<nsINodeInfo*>(he->value)->mDocument = nullptr;
return HT_ENUMERATE_NEXT; return HT_ENUMERATE_NEXT;

View File

@ -116,9 +116,9 @@ protected:
void SetDocumentPrincipal(nsIPrincipal *aPrincipal); void SetDocumentPrincipal(nsIPrincipal *aPrincipal);
private: private:
static PRIntn NodeInfoInnerKeyCompare(const void *key1, const void *key2); static int NodeInfoInnerKeyCompare(const void *key1, const void *key2);
static PLHashNumber GetNodeInfoInnerHashValue(const void *key); static PLHashNumber GetNodeInfoInnerHashValue(const void *key);
static PRIntn DropNodeInfoDocument(PLHashEntry *he, PRIntn hashIndex, static int DropNodeInfoDocument(PLHashEntry *he, int hashIndex,
void *arg); void *arg);
PLHashTable *mNodeInfoHash; PLHashTable *mNodeInfoHash;

View File

@ -381,8 +381,6 @@ MOCHITEST_FILES_B = \
test_bug562652.html \ test_bug562652.html \
test_bug562137.html \ test_bug562137.html \
file_bug562137.txt \ file_bug562137.txt \
test_bug562169-1.html \
test_bug562169-2.html \
test_bug548193.html \ test_bug548193.html \
file_bug548193.sjs \ file_bug548193.sjs \
test_html_colors_quirks.html \ test_html_colors_quirks.html \

View File

@ -32,15 +32,14 @@ function afterLoad() {
iframeDoc.getElementById("password").value = "123456"; iframeDoc.getElementById("password").value = "123456";
iframeDoc.getElementById("hidden").value = "gecko"; iframeDoc.getElementById("hidden").value = "gecko";
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = SpecialPowers.wrap(Components).classes["@mozilla.org/file/directory_service;1"]
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties) .getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsILocalFile); .get("TmpD", Components.interfaces.nsILocalFile);
file.append("345339_test.file"); file.append("345339_test.file");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666); file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0666);
filePath = file.path; filePath = file.path;
iframeDoc.getElementById("file").value = filePath; SpecialPowers.wrap(iframeDoc).getElementById("file").value = filePath;
/* Reload the page */ /* Reload the page */
$("testframe").setAttribute("onload", "afterReload()"); $("testframe").setAttribute("onload", "afterReload()");
@ -62,8 +61,7 @@ function afterReload() {
"password field value forgotten"); "password field value forgotten");
is(iframeDoc.getElementById("hidden").value, "gecko", is(iframeDoc.getElementById("hidden").value, "gecko",
"hidden field value preserved"); "hidden field value preserved");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); is(SpecialPowers.wrap(iframeDoc).getElementById("file").value, filePath,
is(iframeDoc.getElementById("file").value, filePath,
"file field value preserved"); "file field value preserved");
SimpleTest.finish(); SimpleTest.finish();

View File

@ -31,9 +31,10 @@ function eventHandler(evt) {
function test(trusted, type, removeAddedListener, removeSetListener, allowUntrusted) { function test(trusted, type, removeAddedListener, removeSetListener, allowUntrusted) {
if (trusted) { if (trusted) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var x1 = SpecialPowers.wrap(new XMLHttpRequest());
} else {
x1 = new XMLHttpRequest();
} }
var x1 = new XMLHttpRequest();
var handlerCount = 0; var handlerCount = 0;
if (trusted || allowUntrusted || allowUntrusted == undefined) { if (trusted || allowUntrusted || allowUntrusted == undefined) {

View File

@ -22,14 +22,13 @@
request.send(null); request.send(null);
// Try reading headers in privileged context // Try reading headers in privileged context
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); is(SpecialPowers.wrap(request).getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context");
is(request.getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context"); is(SpecialPowers.wrap(request).getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context");
is(request.getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context"); is(SpecialPowers.wrap(request).getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
is(request.getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
ok(/\bSet-Cookie:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in privileged context"); ok(/\bSet-Cookie:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in privileged context");
ok(/\bSet-Cookie2:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in privileged context"); ok(/\bSet-Cookie2:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in privileged context");
ok(/\bX-Dummy:/i.test(request.getAllResponseHeaders()), "Looking for X-Dummy in all response headers in privileged context"); ok(/\bX-Dummy:/i.test(SpecialPowers.wrap(request).getAllResponseHeaders()), "Looking for X-Dummy in all response headers in privileged context");
// Try reading headers in unprivileged context // Try reading headers in unprivileged context
setTimeout(function() { setTimeout(function() {

View File

@ -19,10 +19,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=422537
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/** Test for Bug 422537 **/ /** Test for Bug 422537 **/
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var isupports_string = SpecialPowers.wrap(Components)
.classes["@mozilla.org/supports-string;1"]
var isupports_string = Components.classes["@mozilla.org/supports-string;1"] .createInstance(Components.interfaces.nsISupportsString);
.createInstance(Components.interfaces.nsISupportsString);
isupports_string.data = "foo"; isupports_string.data = "foo";
const url = "http://mochi.test:8888"; const url = "http://mochi.test:8888";
@ -35,12 +34,15 @@ var body = [
for each (var i in body) { for each (var i in body) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", url, true); xhr.open("POST", url, true);
xhr.send(i); if (i == isupports_string)
var chan = SpecialPowers.unwrap(SpecialPowers.wrap(xhr).channel); SpecialPowers.wrap(xhr).send(i);
if (!(chan instanceof Components.interfaces.nsIUploadChannel)) else
xhr.send(i);
var chan = SpecialPowers.wrap(xhr).channel;
if (!SpecialPowers.call_Instanceof(chan, Components.interfaces.nsIUploadChannel))
throw "Must be an upload channel"; throw "Must be an upload channel";
var stream = chan.uploadStream; var stream = chan.uploadStream;
if (!stream || !(stream instanceof Components.interfaces.nsISeekableStream)) if (!stream || !SpecialPowers.call_Instanceof(stream, Components.interfaces.nsISeekableStream))
throw "Stream must be seekable"; throw "Stream must be seekable";
// the following is a no-op, but should not throw an exception // the following is a no-op, but should not throw an exception
stream.seek(Components.interfaces.nsISeekableStream.NS_SEEK_CUR, 0); stream.seek(Components.interfaces.nsISeekableStream.NS_SEEK_CUR, 0);

View File

@ -1,44 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=562169
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 562169</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=562169">Mozilla Bug 562169</a>
<p id="display"></p>
<div id="content" style="display: none">
<div dir="rtl" id="z"></div>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 562169 **/
/** Test that adding an child to an element with dir="rtl" makes the
child have rtl directionality, and removing the child makes it
go back to ltr directionality **/
function checkSelector(element, expectedDir, expectedChild)
{
ok(element.querySelector(":dir("+expectedDir+")") == expectedChild,
"direction should be " + expectedDir);
}
var x = document.createElement("div");
var y = document.createElement("div");
x.appendChild(y);
checkSelector(x, "ltr", y);
$(z).appendChild(x);
checkSelector(x, "rtl", y);
$(z).removeChild(x);
checkSelector(x, "ltr", y);
</script>
</pre>
</body>
</html>

View File

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=562169
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 562169</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=562169">Mozilla Bug 562169</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 562169 **/
/** Test that a newly created element has ltr directionality **/
ok(document.createElement("div").mozMatchesSelector(":dir(ltr)"),
"Element should be ltr on creation");
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,7 @@
<!doctype html>
<canvas></canvas>
<script>
var canvas = document.body.firstChild,
gl = canvas.getContext("experimental-webgl");
gl.texImage2D(0, 0, 0, 0, 0, { width: 10, height: 10, data: 7 });
</script>

View File

@ -0,0 +1,10 @@
<!doctype HTML>
<html>
<body>
<canvas id="c" width="10000" height="10000"></canvas>
<script>
var ctx = document.getElementById("c").getContext("2d");
ctx.fillText("Hello world!", 50, 50);
</script>
</body>
</html>

View File

@ -2,6 +2,7 @@ load 360293-1.html
load 421715-1.html load 421715-1.html
load 553938-1.html load 553938-1.html
load 647480.html load 647480.html
load 727547.html
load 0px-size-font-667225.html load 0px-size-font-667225.html
load texImage2D.html load texImage2D.html
load 729116.html load 729116.html
@ -11,3 +12,4 @@ load 746813-1.html
#load 745818-large-source.html #load 745818-large-source.html
load 743499-negative-size.html load 743499-negative-size.html
load 767337-1.html load 767337-1.html
load 780392-1.html

View File

@ -6,13 +6,14 @@
<script> <script>
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
const Cc = SpecialPowers.wrap(Components).classes;
const Cr = SpecialPowers.wrap(Components).results;
function IsD2DEnabled() { function IsD2DEnabled() {
var enabled = false; var enabled = false;
try { try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); enabled = Cc["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).D2DEnabled;
enabled = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).D2DEnabled;
} catch(e) {} } catch(e) {}
return enabled; return enabled;
@ -26,10 +27,9 @@ function IsMacOSX10_5orOlder() {
var is105orOlder = false; var is105orOlder = false;
if (navigator.platform.indexOf("Mac") == 0) { if (navigator.platform.indexOf("Mac") == 0) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var version = Cc["@mozilla.org/system-info;1"]
var version = Components.classes["@mozilla.org/system-info;1"] .getService(Components.interfaces.nsIPropertyBag2)
.getService(Components.interfaces.nsIPropertyBag2) .getProperty("version");
.getProperty("version");
// the next line is correct: Mac OS 10.6 corresponds to Darwin version 10 ! // the next line is correct: Mac OS 10.6 corresponds to Darwin version 10 !
// Mac OS 10.5 would be Darwin version 9. the |version| string we've got here // Mac OS 10.5 would be Darwin version 9. the |version| string we've got here
// is the Darwin version. // is the Darwin version.
@ -43,8 +43,7 @@ function IsAzureEnabled() {
var enabled = false; var enabled = false;
try { try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var backend = Cc["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
var backend = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
enabled = (backend != "none"); enabled = (backend != "none");
} catch (e) { } } catch (e) { }
@ -55,8 +54,7 @@ function IsAzureSkia() {
var enabled = false; var enabled = false;
try { try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var backend = Cc["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
var backend = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
enabled = (backend == "skia"); enabled = (backend == "skia");
} catch (e) { } } catch (e) { }
@ -67,8 +65,7 @@ function IsAzureCairo() {
var enabled = false; var enabled = false;
try { try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var backend = Cc["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
var backend = Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).getInfo().AzureCanvasBackend;
enabled = (backend == "cairo"); enabled = (backend == "cairo");
} catch (e) { } } catch (e) { }
@ -126,7 +123,8 @@ ok(ctx.canvas === canvas, "ctx.canvas === canvas");
function isPixel(ctx, x,y, r,g,b,a, d) { function isPixel(ctx, x,y, r,g,b,a, d) {
var pos = x + "," + y; var pos = x + "," + y;
var colour = r + "," + g + "," + b + "," + a; var colour = r + "," + g + "," + b + "," + a;
var pixel = ctx.getImageData(x, y, 1, 1); var pixel = SpecialPowers.unwrap(SpecialPowers.wrap(ctx)
.getImageData(x, y, 1, 1));
var pr = pixel.data[0], var pr = pixel.data[0],
pg = pixel.data[1], pg = pixel.data[1],
pb = pixel.data[2], pb = pixel.data[2],
@ -19804,9 +19802,8 @@ function test_bug397524() {
<script> <script>
function test_bug405982() { function test_bug405982() {
var canvas = document.getElementById('c614'); var canvas = SpecialPowers.wrap(document.getElementById('c614'));
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var _threw = false; var _threw = false;
try { try {
@ -21123,7 +21120,6 @@ img.onload = wrapFunction(function ()
ctx667.drawImage(img, 0, 25); ctx667.drawImage(img, 0, 25);
// (The alpha values do not really survive float->int conversion, so just // (The alpha values do not really survive float->int conversion, so just
// do approximate comparisons) // do approximate comparisons)
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
isPixel(ctx667, 12,40, 1,3,254,255, 0); isPixel(ctx667, 12,40, 1,3,254,255, 0);
isPixel(ctx667, 37,40, 8,252,248,191, 2); isPixel(ctx667, 37,40, 8,252,248,191, 2);
isPixel(ctx667, 62,40, 6,10,250,127, 4); isPixel(ctx667, 62,40, 6,10,250,127, 4);
@ -21250,7 +21246,6 @@ deferTest();
img.onload = wrapFunction(function () img.onload = wrapFunction(function ()
{ {
ctx672.drawImage(img, 0, 0); ctx672.drawImage(img, 0, 0);
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
isPixel(ctx672, 12,20, 255,255,0,255, 0); isPixel(ctx672, 12,20, 255,255,0,255, 0);
isPixel(ctx672, 50,20, 0,255,255,255, 0); isPixel(ctx672, 50,20, 0,255,255,255, 0);
isPixel(ctx672, 87,20, 0,0,255,255, 0); isPixel(ctx672, 87,20, 0,0,255,255, 0);

View File

@ -248,10 +248,6 @@ private:
#define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(41) #define NS_EVENT_STATE_VULNERABLE_NO_UPDATE NS_DEFINE_EVENT_STATE_MACRO(41)
// Platform does not support plugin content (some mobile platforms) // Platform does not support plugin content (some mobile platforms)
#define NS_EVENT_STATE_TYPE_UNSUPPORTED_PLATFORM NS_DEFINE_EVENT_STATE_MACRO(42) #define NS_EVENT_STATE_TYPE_UNSUPPORTED_PLATFORM NS_DEFINE_EVENT_STATE_MACRO(42)
// Element is ltr (for :dir pseudo-class)
#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(43)
// Element is rtl (for :dir pseudo-class)
#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(44)
/** /**
* NOTE: do not go over 63 without updating nsEventStates::InternalType! * NOTE: do not go over 63 without updating nsEventStates::InternalType!

View File

@ -50,7 +50,7 @@ nsDOMSimpleGestureEvent::GetDirection(PRUint32 *aDirection)
/* readonly attribute float delta; */ /* readonly attribute float delta; */
NS_IMETHODIMP NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetDelta(PRFloat64 *aDelta) nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
{ {
NS_ENSURE_ARG_POINTER(aDelta); NS_ENSURE_ARG_POINTER(aDelta);
*aDelta = static_cast<nsSimpleGestureEvent*>(mEvent)->delta; *aDelta = static_cast<nsSimpleGestureEvent*>(mEvent)->delta;
@ -83,7 +83,7 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
PRUint16 aButton, PRUint16 aButton,
nsIDOMEventTarget* aRelatedTarget, nsIDOMEventTarget* aRelatedTarget,
PRUint32 aDirectionArg, PRUint32 aDirectionArg,
PRFloat64 aDeltaArg, double aDeltaArg,
PRUint32 aClickCountArg) PRUint32 aClickCountArg)
{ {
nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg, nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,

View File

@ -53,7 +53,6 @@
#include "nsHTMLParts.h" #include "nsHTMLParts.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "nsString.h" #include "nsString.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
@ -97,7 +96,6 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::directionality;
class nsINodeInfo; class nsINodeInfo;
class nsIDOMNodeList; class nsIDOMNodeList;
@ -1689,24 +1687,6 @@ nsGenericHTMLElement::UpdateEditableState(bool aNotify)
nsStyledElement::UpdateEditableState(aNotify); nsStyledElement::UpdateEditableState(aNotify);
} }
nsEventStates
nsGenericHTMLElement::IntrinsicState() const
{
nsEventStates state = nsGenericHTMLElementBase::IntrinsicState();
if (GetDirectionality() == eDir_RTL) {
state |= NS_EVENT_STATE_RTL;
state &= ~NS_EVENT_STATE_LTR;
} else { // at least for HTML, directionality is exclusively LTR or RTL
NS_ASSERTION(GetDirectionality() == eDir_LTR,
"HTML element's directionality must be either RTL or LTR");
state |= NS_EVENT_STATE_LTR;
state &= ~NS_EVENT_STATE_RTL;
}
return state;
}
nsresult nsresult
nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent, nsIContent* aBindingParent,
@ -1909,20 +1889,6 @@ nsGenericHTMLElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
else if (aNotify && aName == nsGkAtoms::spellcheck) { else if (aNotify && aName == nsGkAtoms::spellcheck) {
SyncEditorsOnSubtree(this); SyncEditorsOnSubtree(this);
} }
else if (aName == nsGkAtoms::dir) {
Directionality dir;
if (aValue &&
(aValue->Equals(nsGkAtoms::ltr, eIgnoreCase) ||
aValue->Equals(nsGkAtoms::rtl, eIgnoreCase))) {
SetHasValidDir();
dir = aValue->Equals(nsGkAtoms::rtl, eIgnoreCase) ? eDir_RTL : eDir_LTR;
SetDirectionality(this, dir, aNotify);
} else {
ClearHasValidDir();
dir = RecomputeDirectionality(this, aNotify);
}
SetDirectionalityOnDescendants(this, dir, aNotify);
}
} }
return nsGenericHTMLElementBase::AfterSetAttr(aNamespaceID, aName, return nsGenericHTMLElementBase::AfterSetAttr(aNamespaceID, aName,

View File

@ -49,8 +49,6 @@ public:
{ {
NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML, NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML,
"Unexpected namespace"); "Unexpected namespace");
AddStatesSilently(NS_EVENT_STATE_LTR);
SetFlags(NODE_HAS_DIRECTION_LTR);
} }
/** Typesafe, non-refcounting cast from nsIContent. Cheaper than QI. **/ /** Typesafe, non-refcounting cast from nsIContent. Cheaper than QI. **/
@ -204,8 +202,6 @@ public:
virtual void UpdateEditableState(bool aNotify); virtual void UpdateEditableState(bool aNotify);
virtual nsEventStates IntrinsicState() const;
// Helper for setting our editable flag and notifying // Helper for setting our editable flag and notifying
void DoSetEditableFlag(bool aEditable, bool aNotify) { void DoSetEditableFlag(bool aEditable, bool aNotify) {
SetEditableFlag(aEditable); SetEditableFlag(aEditable);

View File

@ -265,6 +265,7 @@ MOCHITEST_FILES = \
test_bug745685.html \ test_bug745685.html \
test_input_file_picker.html \ test_input_file_picker.html \
test_bug763626.html \ test_bug763626.html \
test_bug780993.html \
$(NULL) $(NULL)
MOCHITEST_BROWSER_FILES = \ MOCHITEST_BROWSER_FILES = \

View File

@ -24,10 +24,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=143220
var leafName; var leafName;
var fullPath; var fullPath;
function initVals() { function initVals() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var dirSvc = SpecialPowers.wrap(Components)
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"] .classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties); .getService(Components.interfaces.nsIProperties);
var file = dirSvc.get("XpcomLib", Components.interfaces.nsILocalFile); var file = dirSvc.get("XpcomLib", Components.interfaces.nsILocalFile);
isnot(file, null, "Must have file here"); isnot(file, null, "Must have file here");
@ -36,15 +37,13 @@ function initVals() {
} }
function initControl1() { function initControl1() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); SpecialPowers.wrap($("i1")).value = fullPath;
$("i1").value = fullPath; is(SpecialPowers.wrap($("i1")).value, fullPath, "Should have set full path 1");
is($("i1").value, fullPath, "Should have set full path 1");
} }
function initControl2() { function initControl2() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); SpecialPowers.wrap($("i2")).value = fullPath;
$("i2").value = fullPath; is(SpecialPowers.wrap($("i2")).value, fullPath, "Should have set full path 2");
is($("i2").value, fullPath, "Should have set full path 2");
} }
initVals(); initVals();

View File

@ -32,26 +32,25 @@ var input2Files =
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
function setFileInputs () { function setFileInputs () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
f = createFileWithData(input1File.name, input1File.body); f = createFileWithData(input1File.name, input1File.body);
singleFileInput.mozSetFileNameArray([f.path], 1); SpecialPowers.wrap(singleFileInput).mozSetFileNameArray([f.path], 1);
var input2FileNames = []; var input2FileNames = [];
for each (file in input2Files) { for each (file in input2Files) {
f = createFileWithData(file.name, file.body); f = createFileWithData(file.name, file.body);
input2FileNames.push(f.path); input2FileNames.push(f.path);
} }
multiFileInput.mozSetFileNameArray(input2FileNames, input2FileNames.length); SpecialPowers.wrap(multiFileInput).mozSetFileNameArray(input2FileNames, input2FileNames.length);
} }
function createFileWithData(fileName, fileData) { function createFileWithData(fileName, fileData) {
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"] var dirSvc = SpecialPowers.wrap(Components).classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties); .getService(Components.interfaces.nsIProperties);
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile); var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
testFile.append(fileName); testFile.append(fileName);
var outStream = Components. var outStream = SpecialPowers.wrap(Components).
classes["@mozilla.org/network/file-output-stream;1"]. classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream); createInstance(Components.interfaces.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0); 0666, 0);
outStream.write(fileData, fileData.length); outStream.write(fileData, fileData.length);

View File

@ -0,0 +1,39 @@
<!doctype html>
<meta charset=utf-8>
<title>Test for bug 780993</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var select = document.createElement("select");
var option = document.createElement("option");
select.appendChild(option);
assert_equals(select[0], option);
select[0] = null;
assert_equals(option.parentNode, null);
assert_equals(select[0], null);
}, "Should be able to set select[n] to null.");
test(function() {
var select = document.createElement("select");
var option = document.createElement("option");
var option2 = document.createElement("option");
select.appendChild(option);
assert_equals(select[0], option);
select[0] = option2;
assert_equals(option.parentNode, null);
assert_equals(option2.parentNode, select);
assert_equals(select[0], option2);
}, "Should be able to set select[n] to an option element");
test(function() {
var select = document.createElement("select");
var option = document.createElement("option");
select.appendChild(option);
assert_equals(select[0], option);
assert_throws(null, function() {
select[0] = 42;
});
assert_equals(option.parentNode, select);
assert_equals(select[0], option);
}, "Should not be able to set select[n] to a primitive.");
</script>

View File

@ -92,7 +92,9 @@ public:
// imgIDecoderObserver (override nsStubImageDecoderObserver) // imgIDecoderObserver (override nsStubImageDecoderObserver)
NS_IMETHOD OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage); NS_IMETHOD OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage);
NS_IMETHOD OnStopContainer(imgIRequest* aRequest, imgIContainer* aImage);
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult aStatus, const PRUnichar *aStatusArg); NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult aStatus, const PRUnichar *aStatusArg);
NS_IMETHOD OnDiscard(imgIRequest *aRequest);
// nsIDOMEventListener // nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
@ -519,6 +521,20 @@ ImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
ImageDocument::OnStopContainer(imgIRequest* aRequest, imgIContainer* aImage)
{
if (mImageContent) {
// Update the background-color of the image only after the
// image has been decoded to prevent flashes of just the
// background-color.
mImageContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("decoded"), true);
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
ImageDocument::OnStopDecode(imgIRequest *aRequest, ImageDocument::OnStopDecode(imgIRequest *aRequest,
nsresult aStatus, nsresult aStatus,
@ -526,12 +542,6 @@ ImageDocument::OnStopDecode(imgIRequest *aRequest,
{ {
UpdateTitleAndCharset(); UpdateTitleAndCharset();
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mImageContent);
if (imageLoader) {
mObservingImageLoader = false;
imageLoader->RemoveObserver(this);
}
// mImageContent can be null if the document is already destroyed // mImageContent can be null if the document is already destroyed
if (NS_FAILED(aStatus) && mStringBundle && mImageContent) { if (NS_FAILED(aStatus) && mStringBundle && mImageContent) {
nsCAutoString src; nsCAutoString src;
@ -549,6 +559,18 @@ ImageDocument::OnStopDecode(imgIRequest *aRequest,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
ImageDocument::OnDiscard(imgIRequest *aRequest)
{
// mImageContent can be null if the document is already destroyed
if (mImageContent) {
// Remove any decoded-related styling when the image is unloaded.
mImageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class,
true);
}
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
ImageDocument::HandleEvent(nsIDOMEvent* aEvent) ImageDocument::HandleEvent(nsIDOMEvent* aEvent)
{ {

View File

@ -55,9 +55,7 @@ function checkURI(uri, name, type) {
function checkFrame(num) { function checkFrame(num) {
// Just snarf our data // Just snarf our data
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var outer = SpecialPowers.wrap(window.frames[num]);
var outer = window.frames[num]
name = outer.name; name = outer.name;
is(outer.document.baseURI, is(outer.document.baseURI,

View File

@ -24,21 +24,19 @@ var frame = document.getElementById("i");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
addLoadEvent(function() { addLoadEvent(function() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var viewer = var viewer =
frame.contentWindow SpecialPowers.wrap(frame.contentWindow
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Components.interfaces.nsIInterfaceRequestor))
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell) .QueryInterface(Components.interfaces.nsIDocShell)
.contentViewer .contentViewer
.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer); .QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
viewer.fullZoom = 1.5; viewer.fullZoom = 1.5;
setTimeout(function() { setTimeout(function() {
synthesizeMouse(frame, 30, 30, {}); synthesizeMouse(frame, 30, 30, {});
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
is(viewer.fullZoom, 1.5, "Zoom in the image frame should not have been reset"); is(viewer.fullZoom, 1.5, "Zoom in the image frame should not have been reset");
SimpleTest.finish(); SimpleTest.finish();

View File

@ -16,8 +16,8 @@ class nsMediaPluginReader : public nsBuiltinDecoderReader
{ {
nsCString mType; nsCString mType;
MPAPI::Decoder *mPlugin; MPAPI::Decoder *mPlugin;
PRBool mHasAudio; bool mHasAudio;
PRBool mHasVideo; bool mHasVideo;
nsIntRect mPicture; nsIntRect mPicture;
nsIntSize mInitialFrame; nsIntSize mInitialFrame;
int64_t mVideoSeekTimeUs; int64_t mVideoSeekTimeUs;

View File

@ -159,10 +159,9 @@ function fileUriToSrc(path, mustExist) {
if (navigator.appVersion.indexOf("Android") != -1) if (navigator.appVersion.indexOf("Android") != -1)
return path; return path;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Ci = Components.interfaces; const Ci = Components.interfaces;
const Cc = Components.classes; const Cc = SpecialPowers.wrap(Components).classes;
const Cr = Components.results; const Cr = SpecialPowers.wrap(Components).results;
var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties); getService(Ci.nsIProperties);
var f = dirSvc.get("CurWorkD", Ci.nsILocalFile); var f = dirSvc.get("CurWorkD", Ci.nsILocalFile);
@ -444,8 +443,7 @@ function MediaTestManager() {
// Force a GC after every completed testcase. This ensures that any decoders // Force a GC after every completed testcase. This ensures that any decoders
// with live threads waiting for the GC are killed promptly, to free up the // with live threads waiting for the GC are killed promptly, to free up the
// thread stacks' address space. // thread stacks' address space.
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); SpecialPowers.forceGC();
Components.utils.forceGC();
while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) { while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) {
var test = this.tests[this.testNum]; var test = this.tests[this.testNum];
@ -497,15 +495,14 @@ function mediaTestCleanup() {
A[i].parentNode.removeChild(A[i]); A[i].parentNode.removeChild(A[i]);
A[i] = null; A[i] = null;
} }
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); SpecialPowers.forceGC();
Components.utils.forceGC();
} }
(function() { (function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Ensure that preload preferences are comsistent // Ensure that preload preferences are comsistent
var prefService = Components.classes["@mozilla.org/preferences-service;1"] var prefService = SpecialPowers.wrap(Components)
.getService(Components.interfaces.nsIPrefService); .classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var branch = prefService.getBranch("media."); var branch = prefService.getBranch("media.");
var oldDefault = 2; var oldDefault = 2;
var oldAuto = 3; var oldAuto = 3;
@ -522,7 +519,6 @@ function mediaTestCleanup() {
branch.setBoolPref("opus.enabled", true); branch.setBoolPref("opus.enabled", true);
window.addEventListener("unload", function() { window.addEventListener("unload", function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
branch.setIntPref("preload.default", oldDefault); branch.setIntPref("preload.default", oldDefault);
branch.setIntPref("preload.auto", oldAuto); branch.setIntPref("preload.auto", oldAuto);
if (oldOpus !== undefined) if (oldOpus !== undefined)

View File

@ -156,7 +156,7 @@ void txDouble::toString(double aValue, nsAString& aDest)
const int buflen = 20; const int buflen = 20;
char buf[buflen]; char buf[buflen];
PRIntn intDigits, sign; int intDigits, sign;
char* endp; char* endp;
PR_dtoa(aValue, 0, 0, &intDigits, &sign, &endp, buf, buflen - 1); PR_dtoa(aValue, 0, 0, &intDigits, &sign, &endp, buf, buflen - 1);

View File

@ -572,7 +572,7 @@ txXPathNodeUtils::getBaseURI(const txXPathNode& aNode, nsAString& aURI)
} }
/* static */ /* static */
PRIntn int
txXPathNodeUtils::comparePosition(const txXPathNode& aNode, txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
const txXPathNode& aOtherNode) const txXPathNode& aOtherNode)
{ {

View File

@ -567,7 +567,7 @@ txNodeSet::findPosition(const txXPathNode& aNode, txXPathNode* aFirst,
// If we search 2 nodes or less there is no point in further divides // If we search 2 nodes or less there is no point in further divides
txXPathNode* pos = aFirst; txXPathNode* pos = aFirst;
for (; pos < aLast; ++pos) { for (; pos < aLast; ++pos) {
PRIntn cmp = txXPathNodeUtils::comparePosition(aNode, *pos); int cmp = txXPathNodeUtils::comparePosition(aNode, *pos);
if (cmp < 0) { if (cmp < 0) {
return pos; return pos;
} }
@ -583,7 +583,7 @@ txNodeSet::findPosition(const txXPathNode& aNode, txXPathNode* aFirst,
// (cannot add two pointers) // (cannot add two pointers)
txXPathNode* midpos = aFirst + (aLast - aFirst) / 2; txXPathNode* midpos = aFirst + (aLast - aFirst) / 2;
PRIntn cmp = txXPathNodeUtils::comparePosition(aNode, *midpos); int cmp = txXPathNodeUtils::comparePosition(aNode, *midpos);
if (cmp == 0) { if (cmp == 0) {
aDupe = true; aDupe = true;

View File

@ -94,8 +94,8 @@ public:
const txXPathNode& aBase, nsAString& aResult); const txXPathNode& aBase, nsAString& aResult);
static void release(txXPathNode* aNode); static void release(txXPathNode* aNode);
static void getBaseURI(const txXPathNode& aNode, nsAString& aURI); static void getBaseURI(const txXPathNode& aNode, nsAString& aURI);
static PRIntn comparePosition(const txXPathNode& aNode, static int comparePosition(const txXPathNode& aNode,
const txXPathNode& aOtherNode); const txXPathNode& aOtherNode);
static bool localNameEquals(const txXPathNode& aNode, static bool localNameEquals(const txXPathNode& aNode,
nsIAtom* aLocalName); nsIAtom* aLocalName);
static bool isRoot(const txXPathNode& aNode); static bool isRoot(const txXPathNode& aNode);

View File

@ -277,7 +277,7 @@ txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext,
char* buf = new char[bufsize]; char* buf = new char[bufsize];
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
PRIntn bufIntDigits, sign; int bufIntDigits, sign;
char* endp; char* endp;
PR_dtoa(value, 0, 0, &bufIntDigits, &sign, &endp, buf, bufsize-1); PR_dtoa(value, 0, 0, &bufIntDigits, &sign, &endp, buf, bufsize-1);

View File

@ -205,7 +205,7 @@ Instantiation::Hash(const void* aKey)
} }
PRIntn int
Instantiation::Compare(const void* aLeft, const void* aRight) Instantiation::Compare(const void* aLeft, const void* aRight)
{ {
const Instantiation* left = static_cast<const Instantiation*>(aLeft); const Instantiation* left = static_cast<const Instantiation*>(aLeft);

View File

@ -466,7 +466,7 @@ public:
return !Equals(aInstantiation); } return !Equals(aInstantiation); }
static PLHashNumber Hash(const void* aKey); static PLHashNumber Hash(const void* aKey);
static PRIntn Compare(const void* aLeft, const void* aRight); static int Compare(const void* aLeft, const void* aRight);
}; };

View File

@ -335,7 +335,7 @@ nsXULTemplateQueryProcessorStorage::CompileQuery(nsIXULTemplateBuilder* aBuilder
rv = NS_ERROR_ILLEGAL_VALUE; rv = NS_ERROR_ILLEGAL_VALUE;
PRInt32 valInt32 = 0; PRInt32 valInt32 = 0;
PRInt64 valInt64 = 0; PRInt64 valInt64 = 0;
PRFloat64 valFloat = 0; double valFloat = 0;
switch (typeValue) { switch (typeValue) {
case 0: case 0:

View File

@ -6055,17 +6055,19 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
channel->GetURI(getter_AddRefs(uri)); channel->GetURI(getter_AddRefs(uri));
nsCAutoString aURI; nsCAutoString aURI;
uri->GetAsciiSpec(aURI); uri->GetAsciiSpec(aURI);
if (this == aProgress){
nsCOMPtr<nsIWyciwygChannel> wcwgChannel(do_QueryInterface(aRequest));
nsCOMPtr<nsIWebProgress> webProgress =
do_QueryInterface(GetAsSupports(this));
// We don't update navigation timing for wyciwyg channels
if (this == aProgress && !wcwgChannel){
rv = MaybeInitTiming(); rv = MaybeInitTiming();
if (mTiming) { if (mTiming) {
mTiming->NotifyFetchStart(uri, ConvertLoadTypeToNavigationType(mLoadType)); mTiming->NotifyFetchStart(uri, ConvertLoadTypeToNavigationType(mLoadType));
} }
} }
nsCOMPtr<nsIWyciwygChannel> wcwgChannel(do_QueryInterface(aRequest));
nsCOMPtr<nsIWebProgress> webProgress =
do_QueryInterface(GetAsSupports(this));
// Was the wyciwyg document loaded on this docshell? // Was the wyciwyg document loaded on this docshell?
if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) { if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) {
bool equalUri = true; bool equalUri = true;

View File

@ -95,6 +95,8 @@ MOCHITEST_FILES = \
test_bug691547.html \ test_bug691547.html \
bug691547_frame.html \ bug691547_frame.html \
test_bug694612.html \ test_bug694612.html \
test_bug703855.html \
file_bug703855.html \
test_bug713825.html \ test_bug713825.html \
test_bug728939.html \ test_bug728939.html \
file_bug728939.html \ file_bug728939.html \

View File

@ -0,0 +1,2 @@
<!DOCTYPE html>
<!-- Just need an empty file here, as long as it's served over HTTP -->

View File

@ -98,17 +98,18 @@ function isInaccessible(wnd, message) {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
function xpcEnumerateContentWindows(callback) { function xpcEnumerateContentWindows(callback) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var Ci = Components.interfaces; var Ci = Components.interfaces;
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] var ww = SpecialPowers.wrap(Components)
.getService(Ci.nsIWindowWatcher); .classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Ci.nsIWindowWatcher);
var enumerator = ww.getWindowEnumerator(); var enumerator = ww.getWindowEnumerator();
var contentWindows = []; var contentWindows = [];
while (enumerator.hasMoreElements()) { while (enumerator.hasMoreElements()) {
var win = enumerator.getNext(); var win = enumerator.getNext();
if (typeof ChromeWindow != "undefined" && win instanceof ChromeWindow) { if (typeof ChromeWindow != "undefined" && SpecialPowers.call_Instanceof(win, ChromeWindow)) {
var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor) var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeNode); .QueryInterface(Ci.nsIDocShellTreeNode);

View File

@ -4,7 +4,6 @@
function testDone() { function testDone() {
document.body.removeChild(document.body.firstChild); document.body.removeChild(document.body.firstChild);
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var isOK = false; var isOK = false;
try { try {
isOK = history.previous != location; isOK = history.previous != location;

View File

@ -60,7 +60,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
} }
function beginTest() { function beginTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gTest.window.document.body.focus(); gTest.window.document.body.focus();
// WARNING: If the following test fails, give the setTimeout() in the onload() // WARNING: If the following test fails, give the setTimeout() in the onload()
@ -74,7 +73,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
} }
function goBack() { function goBack() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gTest.window.history.back(); gTest.window.history.back();
setTimeout(function() { setTimeout(function() {
SimpleTest.waitForFocus(checkStillEditable, gTest.window); SimpleTest.waitForFocus(checkStillEditable, gTest.window);
@ -82,7 +80,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
} }
function checkStillEditable() { function checkStillEditable() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Check that the contents are correct. // Check that the contents are correct.
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Edited contents still correct?"); is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Edited contents still correct?");

View File

@ -186,9 +186,9 @@ var gNextTest = 0;
function runNextTest() function runNextTest()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = SpecialPowers.wrap(Components)
var prefs = Components.classes["@mozilla.org/preferences-service;1"]. .classes["@mozilla.org/preferences-service;1"]
getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
if (gNextTest < gTests.length) { if (gNextTest < gTests.length) {
gCurrentTest = gTests[gNextTest++]; gCurrentTest = gTests[gNextTest++];
@ -214,9 +214,9 @@ function runNextTest()
function finishTest() function finishTest()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = SpecialPowers.wrap(Components)
var prefs = Components.classes["@mozilla.org/preferences-service;1"]. .classes["@mozilla.org/preferences-service;1"]
getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref("network.jar.open-unsafe-types", false); prefs.setBoolPref("network.jar.open-unsafe-types", false);
if (gNumPokes == 0) { if (gNumPokes == 0) {
@ -228,9 +228,9 @@ function finishTest()
function startTests() function startTests()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = SpecialPowers.wrap(Components)
var prefs = Components.classes["@mozilla.org/preferences-service;1"]. .classes["@mozilla.org/preferences-service;1"]
getService(Components.interfaces.nsIPrefBranch); .getService(Components.interfaces.nsIPrefBranch);
gPrefValue = prefs.getBoolPref("network.jar.open-unsafe-types"); gPrefValue = prefs.getBoolPref("network.jar.open-unsafe-types");
} }

View File

@ -41,8 +41,6 @@ function onChildLoad(e) {
} }
function runTest() { function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var popup = window.open("file_bug509055.html", "popup 0", var popup = window.open("file_bug509055.html", "popup 0",
"height=200,width=200,location=yes," + "height=200,width=200,location=yes," +
"menubar=yes,status=yes,toolbar=yes,dependent=yes"); "menubar=yes,status=yes,toolbar=yes,dependent=yes");
@ -72,9 +70,10 @@ function runTest() {
dump('Got second hashchange. Spinning event loop.\n'); dump('Got second hashchange. Spinning event loop.\n');
yield; yield;
var sh = popup.QueryInterface(Components.interfaces.nsIInterfaceRequestor) var sh = SpecialPowers.wrap(popup)
.getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.sessionHistory; .getInterface(Components.interfaces.nsIWebNavigation)
.sessionHistory;
// Get the title of the inner popup's current SHEntry // Get the title of the inner popup's current SHEntry
var sheTitle = sh.getEntryAtIndex(sh.index, false).title; var sheTitle = sh.getEntryAtIndex(sh.index, false).title;

View File

@ -43,7 +43,6 @@ function pollForPage(f, w)
function windowLoaded() function windowLoaded()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
switch (phase) switch (phase)
{ {
case 0: case 0:
@ -57,18 +56,16 @@ function windowLoaded()
pollForPage(function(succeeded) { pollForPage(function(succeeded) {
ok(succeeded, "Waiting for error page succeeded"); ok(succeeded, "Waiting for error page succeeded");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/* 3. now, while we are on the error page, try to reload it, actually /* 3. now, while we are on the error page, try to reload it, actually
click the "Try Again" button */ click the "Try Again" button */
w.location.reload(); SpecialPowers.wrap(w).location.reload();
pollForPage(function(succeeded) { pollForPage(function(succeeded) {
ok(succeeded, "Waiting for error page succeeded"); ok(succeeded, "Waiting for error page succeeded");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/* 4-finish, check we are still on the error page */ /* 4-finish, check we are still on the error page */
is(w.location.href, faultyURL, "Is on an error page"); is(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
isnot(w.location.href, workingURL, "Is not on the previous page"); isnot(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
is(gotWrongPageOnTryAgainClick, false, is(gotWrongPageOnTryAgainClick, false,
"Must not get www.example.com page on reload of an error page"); "Must not get www.example.com page on reload of an error page");
w.close(); w.close();

View File

@ -42,8 +42,6 @@ function pollForPage(expectErrorPage, f, w)
function windowLoaded() function windowLoaded()
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/* 2. We have successfully loaded a page, now go to a faulty URL */ /* 2. We have successfully loaded a page, now go to a faulty URL */
// XXX The test fails when we change the location synchronously // XXX The test fails when we change the location synchronously
window.setTimeout(function() { window.setTimeout(function() {
@ -52,11 +50,9 @@ function windowLoaded()
pollForPage(true, function(succeeded) { pollForPage(true, function(succeeded) {
ok(succeeded, "Waiting for error page succeeded"); ok(succeeded, "Waiting for error page succeeded");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/* 3. now, while we are on the error page, navigate back */ /* 3. now, while we are on the error page, navigate back */
try { try {
w.back(); SpecialPowers.wrap(w).back();
} }
catch(ex) { catch(ex) {
ok(false, "w.back() threw " + ex); ok(false, "w.back() threw " + ex);
@ -64,11 +60,9 @@ function windowLoaded()
pollForPage(false, function(succeeded) { pollForPage(false, function(succeeded) {
ok(succeeded, "Waiting for original page succeeded"); ok(succeeded, "Waiting for original page succeeded");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
/* 4-finish, check we are back at the original page */ /* 4-finish, check we are back at the original page */
isnot(w.location.href, faultyURL, "Is on an error page"); isnot(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
is(w.location.href, workingURL, "Is not on the previous page"); is(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
w.close(); w.close();
SimpleTest.finish(); SimpleTest.finish();
}, w); }, w);

View File

@ -0,0 +1,79 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=703855
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 703855</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=703855">Mozilla Bug 703855</a>
<p id="display"></p>
<div id="content" style="display: none">
<iframe id="f" src="file_bug703855.html"></iframe>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 703855 **/
SimpleTest.waitForExplicitFinish();
var timingAttributes = [
'connectEnd',
'connectStart',
'domComplete',
'domContentLoadedEventEnd',
'domContentLoadedEventStart',
'domInteractive',
'domLoading',
'domainLookupEnd',
'domainLookupStart',
'fetchStart',
'loadEventEnd',
'loadEventStart',
'navigationStart',
'redirectEnd',
'redirectStart',
'requestStart',
'responseEnd',
'responseStart',
'unloadEventEnd',
'unloadEventStart'
];
var originalTiming = {};
function runTest() {
var timing = $("f").contentWindow.performance.timing;
for (i in timingAttributes) {
originalTiming[timingAttributes[i]] = timing[timingAttributes[i]];
}
var doc = $("f").contentDocument;
doc.open();
doc.write("<!DOCTYPE html>");
doc.close();
SimpleTest.executeSoon(function() {
var newTiming = $("f").contentWindow.performance.timing;
for (var i in timingAttributes) {
is(timing[timingAttributes[i]], originalTiming[timingAttributes[i]],
"document.open should not affect value of " + timingAttributes[i]);
}
SimpleTest.finish();
});
}
addLoadEvent(function() {
SimpleTest.executeSoon(runTest);
});
</script>
</pre>
</body>
</html>

View File

@ -53,6 +53,26 @@ AppsService.prototype = {
} }
}, },
getAppByLocalId: function getAppByLocalId(aLocalId) {
debug("getAppByLocalId( " + aLocalId + " )");
if (this.inParent) {
return DOMApplicationRegistry.getAppByLocalId(aLocalId);
} else {
return this.cpmm.sendSyncMessage("WebApps:GetAppByLocalId",
{ id: aLocalId })[0];
}
},
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
debug("getManifestURLByLocalId( " + aLocalId + " )");
if (this.inParent) {
return DOMApplicationRegistry.getManifestURLByLocalId(aLocalId);
} else {
return this.cpmm.sendSyncMessage("WebApps:GetManifestURLByLocalId",
{ id: aLocalId })[0];
}
},
classID : APPS_SERVICE_CID, classID : APPS_SERVICE_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService]) QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
} }

View File

@ -57,7 +57,8 @@ let DOMApplicationRegistry = {
"Webapps:GetInstalled", "Webapps:GetNotInstalled", "Webapps:GetInstalled", "Webapps:GetNotInstalled",
"Webapps:Launch", "Webapps:GetAll", "Webapps:Launch", "Webapps:GetAll",
"Webapps:InstallPackage", "Webapps:GetBasePath", "Webapps:InstallPackage", "Webapps:GetBasePath",
"WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL"]; "WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL",
"WebApps:GetAppByLocalId", "Webapps:GetManifestURLByLocalId"];
this.messages.forEach((function(msgName) { this.messages.forEach((function(msgName) {
ppmm.addMessageListener(msgName, this); ppmm.addMessageListener(msgName, this);
@ -220,6 +221,7 @@ let DOMApplicationRegistry = {
this.getSelf(msg); this.getSelf(msg);
break; break;
case "Webapps:Uninstall": case "Webapps:Uninstall":
Services.obs.notifyObservers(this, "webapps-uninstall", JSON.stringify(msg));
this.uninstall(msg); this.uninstall(msg);
break; break;
case "Webapps:Launch": case "Webapps:Launch":
@ -249,6 +251,12 @@ let DOMApplicationRegistry = {
case "WebApps:GetAppLocalIdByManifestURL": case "WebApps:GetAppLocalIdByManifestURL":
return { id: this.getAppLocalIdByManifestURL(msg.url) }; return { id: this.getAppLocalIdByManifestURL(msg.url) };
break; break;
case "WebApps:GetAppByLocalId":
return this.getAppByLocalId(msg.id);
break;
case "WebApps:GetManifestURLByLocalId":
return this.getManifestURLByLocalId(msg.id);
break;
} }
}, },
@ -691,6 +699,35 @@ let DOMApplicationRegistry = {
for (let id in this.webapps) { for (let id in this.webapps) {
let app = this.webapps[id]; let app = this.webapps[id];
if (app.manifestURL == aManifestURL) { if (app.manifestURL == aManifestURL) {
let res = this._cloneAppObject(app);
res.hasPermission = function(permission) {
let localId = DOMApplicationRegistry.getAppLocalIdByManifestURL(
this.manifestURL);
let uri = Services.io.newURI(this.manifestURL, null, null);
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
// XXX for the purposes of permissions checking, this helper
// should always be called on !isBrowser frames, so we
// assume false here.
let principal = secMan.getAppCodebasePrincipal(uri, localId,
/*mozbrowser*/false);
let perm = Services.perms.testExactPermissionFromPrincipal(principal,
permission);
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
};
res.QueryInterface = XPCOMUtils.generateQI([Ci.mozIDOMApplication,
Ci.mozIApplication]);
return res;
}
}
return null;
},
getAppByLocalId: function(aLocalId) {
for (let id in this.webapps) {
let app = this.webapps[id];
if (app.localId == aLocalId) {
return this._cloneAppObject(app); return this._cloneAppObject(app);
} }
} }
@ -698,6 +735,17 @@ let DOMApplicationRegistry = {
return null; return null;
}, },
getManifestURLByLocalId: function(aLocalId) {
for (let id in this.webapps) {
let app = this.webapps[id];
if (app.localId == aLocalId) {
return app.manifestURL;
}
}
return null;
},
getAppLocalIdByManifestURL: function(aManifestURL) { getAppLocalIdByManifestURL: function(aManifestURL) {
for (let id in this.webapps) { for (let id in this.webapps) {
if (this.webapps[id].manifestURL == aManifestURL) { if (this.webapps[id].manifestURL == aManifestURL) {
@ -928,6 +976,10 @@ DOMApplicationManifest.prototype = {
return this._localeProp("appcache_path"); return this._localeProp("appcache_path");
}, },
get orientation() {
return this._localeProp("orientation");
},
iconURLForSize: function(aSize) { iconURLForSize: function(aSize) {
let icons = this._localeProp("icons"); let icons = this._localeProp("icons");
if (!icons) if (!icons)

View File

@ -7,10 +7,11 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIPrincipal.h"
#include "mozilla/unused.h" #include "mozilla/unused.h"
using mozilla::unused; // <snicker> using mozilla::unused; // <snicker>
using namespace mozilla::dom;
nsContentPermissionRequestProxy::nsContentPermissionRequestProxy() nsContentPermissionRequestProxy::nsContentPermissionRequestProxy()
{ {
@ -24,7 +25,7 @@ nsContentPermissionRequestProxy::~nsContentPermissionRequestProxy()
nsresult nsresult
nsContentPermissionRequestProxy::Init(const nsACString & type, nsContentPermissionRequestProxy::Init(const nsACString & type,
mozilla::dom::ContentPermissionRequestParent* parent) ContentPermissionRequestParent* parent)
{ {
NS_ASSERTION(parent, "null parent"); NS_ASSERTION(parent, "null parent");
mParent = parent; mParent = parent;
@ -63,13 +64,14 @@ nsContentPermissionRequestProxy::GetWindow(nsIDOMWindow * *aRequestingWindow)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsContentPermissionRequestProxy::GetUri(nsIURI * *aRequestingURI) nsContentPermissionRequestProxy::GetPrincipal(nsIPrincipal * *aRequestingPrincipal)
{ {
NS_ENSURE_ARG_POINTER(aRequestingURI); NS_ENSURE_ARG_POINTER(aRequestingPrincipal);
if (mParent == nullptr) if (mParent == nullptr) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
NS_ADDREF(*aRequestingURI = mParent->mURI); NS_ADDREF(*aRequestingPrincipal = mParent->mPrincipal);
return NS_OK; return NS_OK;
} }
@ -77,8 +79,10 @@ NS_IMETHODIMP
nsContentPermissionRequestProxy::GetElement(nsIDOMElement * *aRequestingElement) nsContentPermissionRequestProxy::GetElement(nsIDOMElement * *aRequestingElement)
{ {
NS_ENSURE_ARG_POINTER(aRequestingElement); NS_ENSURE_ARG_POINTER(aRequestingElement);
if (mParent == nullptr) if (mParent == nullptr) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
NS_ADDREF(*aRequestingElement = mParent->mElement); NS_ADDREF(*aRequestingElement = mParent->mElement);
return NS_OK; return NS_OK;
} }
@ -86,9 +90,11 @@ nsContentPermissionRequestProxy::GetElement(nsIDOMElement * *aRequestingElement)
NS_IMETHODIMP NS_IMETHODIMP
nsContentPermissionRequestProxy::Cancel() nsContentPermissionRequestProxy::Cancel()
{ {
if (mParent == nullptr) if (mParent == nullptr) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, false); }
unused << ContentPermissionRequestParent::Send__delete__(mParent, false);
mParent = nullptr; mParent = nullptr;
return NS_OK; return NS_OK;
} }
@ -96,9 +102,10 @@ nsContentPermissionRequestProxy::Cancel()
NS_IMETHODIMP NS_IMETHODIMP
nsContentPermissionRequestProxy::Allow() nsContentPermissionRequestProxy::Allow()
{ {
if (mParent == nullptr) if (mParent == nullptr) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, true); }
unused << ContentPermissionRequestParent::Send__delete__(mParent, true);
mParent = nullptr; mParent = nullptr;
return NS_OK; return NS_OK;
} }
@ -108,11 +115,11 @@ namespace dom {
ContentPermissionRequestParent::ContentPermissionRequestParent(const nsACString& aType, ContentPermissionRequestParent::ContentPermissionRequestParent(const nsACString& aType,
nsIDOMElement *aElement, nsIDOMElement *aElement,
const IPC::URI& aUri) const IPC::Principal& aPrincipal)
{ {
MOZ_COUNT_CTOR(ContentPermissionRequestParent); MOZ_COUNT_CTOR(ContentPermissionRequestParent);
mURI = aUri; mPrincipal = aPrincipal;
mElement = aElement; mElement = aElement;
mType = aType; mType = aType;
} }
@ -127,8 +134,9 @@ ContentPermissionRequestParent::Recvprompt()
{ {
mProxy = new nsContentPermissionRequestProxy(); mProxy = new nsContentPermissionRequestProxy();
NS_ASSERTION(mProxy, "Alloc of request proxy failed"); NS_ASSERTION(mProxy, "Alloc of request proxy failed");
if (NS_FAILED(mProxy->Init(mType, this))) if (NS_FAILED(mProxy->Init(mType, this))) {
mProxy->Cancel(); mProxy->Cancel();
}
return true; return true;
} }

View File

@ -11,6 +11,7 @@
#include "nsString.h" #include "nsString.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/PContentPermissionRequestParent.h" #include "mozilla/dom/PContentPermissionRequestParent.h"
class nsContentPermissionRequestProxy; class nsContentPermissionRequestProxy;
@ -21,19 +22,19 @@ namespace dom {
class ContentPermissionRequestParent : public PContentPermissionRequestParent class ContentPermissionRequestParent : public PContentPermissionRequestParent
{ {
public: public:
ContentPermissionRequestParent(const nsACString& type, nsIDOMElement *element, const IPC::URI& principal); ContentPermissionRequestParent(const nsACString& type, nsIDOMElement *element, const IPC::Principal& principal);
virtual ~ContentPermissionRequestParent(); virtual ~ContentPermissionRequestParent();
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIPrincipal> mPrincipal;
nsCOMPtr<nsIDOMElement> mElement; nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsContentPermissionRequestProxy> mProxy; nsCOMPtr<nsContentPermissionRequestProxy> mProxy;
nsCString mType; nsCString mType;
private: private:
virtual bool Recvprompt(); virtual bool Recvprompt();
virtual void ActorDestroy(ActorDestroyReason why); virtual void ActorDestroy(ActorDestroyReason why);
}; };
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@ -42,10 +43,10 @@ class nsContentPermissionRequestProxy : public nsIContentPermissionRequest
public: public:
nsContentPermissionRequestProxy(); nsContentPermissionRequestProxy();
virtual ~nsContentPermissionRequestProxy(); virtual ~nsContentPermissionRequestProxy();
nsresult Init(const nsACString& type, mozilla::dom::ContentPermissionRequestParent* parent); nsresult Init(const nsACString& type, mozilla::dom::ContentPermissionRequestParent* parent);
void OnParentDestroyed(); void OnParentDestroyed();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTPERMISSIONREQUEST NS_DECL_NSICONTENTPERMISSIONREQUEST

View File

@ -1707,24 +1707,30 @@ struct nsContractIDMapData
const char *mContractID; const char *mContractID;
}; };
#define NS_DEFINE_CONSTRUCTOR_DATA(_class, _contract_id) \ #define NS_DEFINE_CONTRACT_CTOR(_class, _contract_id) \
{ eDOMClassInfo_##_class##_id, _contract_id }, nsresult \
_class##Ctor(nsISupports** aInstancePtrResult) \
{ \
nsresult rv = NS_OK; \
nsCOMPtr<nsISupports> native = do_CreateInstance(_contract_id, &rv); \
native.forget(aInstancePtrResult); \
return rv; \
}
static const nsContractIDMapData kConstructorMap[] = NS_DEFINE_CONTRACT_CTOR(DOMParser, NS_DOMPARSER_CONTRACTID)
{ NS_DEFINE_CONTRACT_CTOR(FileReader, NS_FILEREADER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(DOMParser, NS_DOMPARSER_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(ArchiveReader, NS_ARCHIVEREADER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(FileReader, NS_FILEREADER_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(FormData, NS_FORMDATA_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(ArchiveReader, NS_ARCHIVEREADER_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(FormData, NS_FORMDATA_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(WebSocket, NS_WEBSOCKET_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(WebSocket, NS_WEBSOCKET_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(XSLTProcessor,
NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID) "@mozilla.org/document-transformer;1?type=xslt")
NS_DEFINE_CONSTRUCTOR_DATA(XSLTProcessor, NS_DEFINE_CONTRACT_CTOR(EventSource, NS_EVENTSOURCE_CONTRACTID)
"@mozilla.org/document-transformer;1?type=xslt") NS_DEFINE_CONTRACT_CTOR(MutationObserver, NS_DOMMUTATIONOBSERVER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(EventSource, NS_EVENTSOURCE_CONTRACTID) NS_DEFINE_CONTRACT_CTOR(MozActivity, NS_DOMACTIVITY_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(MutationObserver, NS_DOMMUTATIONOBSERVER_CONTRACTID)
NS_DEFINE_CONSTRUCTOR_DATA(MozActivity, NS_DOMACTIVITY_CONTRACTID) #undef NS_DEFINE_CONTRACT_CTOR
};
#define NS_DEFINE_EVENT_CTOR(_class) \ #define NS_DEFINE_EVENT_CTOR(_class) \
nsresult \ nsresult \
@ -1787,6 +1793,17 @@ static const nsConstructorFuncMapData kConstructorFuncMap[] =
#include "GeneratedEvents.h" #include "GeneratedEvents.h"
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter) NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XMLHttpRequest, NS_XMLHttpRequestCtor) NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XMLHttpRequest, NS_XMLHttpRequestCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(DOMParser, DOMParserCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(FileReader, FileReaderCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(ArchiveReader, ArchiveReaderCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(FormData, FormDataCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XMLSerializer, XMLSerializerCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(WebSocket, WebSocketCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XPathEvaluator, XPathEvaluatorCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(EventSource, EventSourceCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MutationObserver, MutationObserverCtor)
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozActivity, MozActivityCtor)
}; };
nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr; nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
@ -1800,7 +1817,6 @@ jsid nsDOMClassInfo::sParent_id = JSID_VOID;
jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID; jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID;
jsid nsDOMClassInfo::sLocation_id = JSID_VOID; jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
jsid nsDOMClassInfo::sConstructor_id = JSID_VOID; jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
jsid nsDOMClassInfo::s_content_id = JSID_VOID;
jsid nsDOMClassInfo::sContent_id = JSID_VOID; jsid nsDOMClassInfo::sContent_id = JSID_VOID;
jsid nsDOMClassInfo::sMenubar_id = JSID_VOID; jsid nsDOMClassInfo::sMenubar_id = JSID_VOID;
jsid nsDOMClassInfo::sToolbar_id = JSID_VOID; jsid nsDOMClassInfo::sToolbar_id = JSID_VOID;
@ -2077,7 +2093,6 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars"); SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
SET_JSID_TO_STRING(sLocation_id, cx, "location"); SET_JSID_TO_STRING(sLocation_id, cx, "location");
SET_JSID_TO_STRING(sConstructor_id, cx, "constructor"); SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
SET_JSID_TO_STRING(s_content_id, cx, "_content");
SET_JSID_TO_STRING(sContent_id, cx, "content"); SET_JSID_TO_STRING(sContent_id, cx, "content");
SET_JSID_TO_STRING(sMenubar_id, cx, "menubar"); SET_JSID_TO_STRING(sMenubar_id, cx, "menubar");
SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar"); SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar");
@ -2183,23 +2198,6 @@ CutPrefix(const char *aName) {
return aName; return aName;
} }
// static
nsresult
nsDOMClassInfo::RegisterClassName(PRInt32 aClassInfoID)
{
nsScriptNameSpaceManager *nameSpaceManager =
nsJSRuntime::GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
nameSpaceManager->RegisterClassName(sClassInfoData[aClassInfoID].mName,
aClassInfoID,
sClassInfoData[aClassInfoID].mChromeOnly,
sClassInfoData[aClassInfoID].mDisabled,
&sClassInfoData[aClassInfoID].mNameUTF16);
return NS_OK;
}
// static // static
nsresult nsresult
nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID) nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID)
@ -4545,7 +4543,9 @@ nsDOMClassInfo::Init()
PRInt32 i; PRInt32 i;
for (i = 0; i < eDOMClassInfoIDCount; ++i) { for (i = 0; i < eDOMClassInfoIDCount; ++i) {
RegisterClassName(i); nsDOMClassInfoData& data = sClassInfoData[i];
nameSpaceManager->RegisterClassName(data.mName, i, data.mChromeOnly,
data.mDisabled, &data.mNameUTF16);
} }
for (i = 0; i < eDOMClassInfoIDCount; ++i) { for (i = 0; i < eDOMClassInfoIDCount; ++i) {
@ -5204,7 +5204,6 @@ nsDOMClassInfo::ShutDown()
sScrollbars_id = JSID_VOID; sScrollbars_id = JSID_VOID;
sLocation_id = JSID_VOID; sLocation_id = JSID_VOID;
sConstructor_id = JSID_VOID; sConstructor_id = JSID_VOID;
s_content_id = JSID_VOID;
sContent_id = JSID_VOID; sContent_id = JSID_VOID;
sMenubar_id = JSID_VOID; sMenubar_id = JSID_VOID;
sToolbar_id = JSID_VOID; sToolbar_id = JSID_VOID;
@ -5643,19 +5642,6 @@ nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK; return NS_OK;
} }
static const char*
FindConstructorContractID(const nsDOMClassInfoData *aDOMClassInfoData)
{
PRUint32 i;
for (i = 0; i < ArrayLength(kConstructorMap); ++i) {
if (&sClassInfoData[kConstructorMap[i].mDOMClassInfoID] ==
aDOMClassInfoData) {
return kConstructorMap[i].mContractID;
}
}
return nullptr;
}
static nsDOMConstructorFunc static nsDOMConstructorFunc
FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData) FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
{ {
@ -5678,18 +5664,11 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) { if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
const nsDOMClassInfoData* ci_data = const nsDOMClassInfoData* ci_data =
&sClassInfoData[name_struct->mDOMClassInfoID]; &sClassInfoData[name_struct->mDOMClassInfoID];
const char *contractid = FindConstructorContractID(ci_data); nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
if (contractid) { if (func) {
native = do_CreateInstance(contractid, &rv); rv = func(getter_AddRefs(native));
} } else {
else { rv = NS_ERROR_NOT_AVAILABLE;
nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
if (func) {
rv = func(getter_AddRefs(native));
}
else {
rv = NS_ERROR_NOT_AVAILABLE;
}
} }
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) { } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
native = do_CreateInstance(name_struct->mCID, &rv); native = do_CreateInstance(name_struct->mCID, &rv);
@ -6102,7 +6081,7 @@ private:
return data->mConstructorCID != nullptr; return data->mConstructorCID != nullptr;
} }
return FindConstructorContractID(aData) || FindConstructorFunc(aData); return FindConstructorFunc(aData);
} }
static bool IsConstructable(const nsGlobalNameStruct *aNameStruct) static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
{ {
@ -6962,18 +6941,6 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
return rv; return rv;
} }
// Native code for window._content getter, this simply maps
// window._content to window.content for backwards compatibility only.
static JSBool
ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
{
JSObject *obj = JS_THIS_OBJECT(cx, vp);
if (!obj)
return JS_FALSE;
return ::JS_GetProperty(cx, obj, "content", vp);
}
static JSNewResolveOp sOtherResolveFuncs[] = { static JSNewResolveOp sOtherResolveFuncs[] = {
mozilla::dom::workers::ResolveWorkerClasses mozilla::dom::workers::ResolveWorkerClasses
}; };
@ -7085,68 +7052,66 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsIScriptContext *my_context = win->GetContextInternal(); nsIScriptContext *my_context = win->GetContextInternal();
nsresult rv = NS_OK;
// Resolve standard classes on my_context's JSContext (or on cx, // Resolve standard classes on my_context's JSContext (or on cx,
// if we don't have a my_context yet), in case the two contexts // if we don't have a my_context yet), in case the two contexts
// have different origins. We want lazy standard class // have different origins. We want lazy standard class
// initialization to behave as if it were done eagerly, on each // initialization to behave as if it were done eagerly, on each
// window's own context (not on some other window-caller's // window's own context (not on some other window-caller's
// context). // context).
JSBool did_resolve = JS_FALSE;
JSContext *my_cx;
JSBool ok = JS_TRUE;
jsval exn = JSVAL_VOID;
if (!ObjectIsNativeWrapper(cx, obj)) { if (!ObjectIsNativeWrapper(cx, obj)) {
JSAutoEnterCompartment ac; JSBool did_resolve = JS_FALSE;
JSBool ok = JS_TRUE;
JS::Value exn = JSVAL_VOID;
if (!my_context) { {
my_cx = cx; JSAutoEnterCompartment ac;
} else {
my_cx = my_context->GetNativeContext();
if (my_cx != cx) { JSContext* my_cx;
if (!ac.enter(my_cx, obj)) { if (!my_context) {
return NS_ERROR_UNEXPECTED; my_cx = cx;
} else {
my_cx = my_context->GetNativeContext();
if (my_cx != cx) {
if (!ac.enter(my_cx, obj)) {
return NS_ERROR_UNEXPECTED;
}
} }
} }
JSAutoRequest transfer(my_cx);
// Don't resolve standard classes on XPCNativeWrapper etc, only
// resolve them if we're resolving on the real global object.
ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
if (!ok) {
// Trust the JS engine (or the script security manager) to set
// the exception in the JS engine.
if (!JS_GetPendingException(my_cx, &exn)) {
return NS_ERROR_UNEXPECTED;
}
// Return NS_OK to avoid stomping over the exception that was passed
// down from the ResolveStandardClass call.
// Note that the order of the JS_ClearPendingException and
// JS_SetPendingException is important in the case that my_cx == cx.
JS_ClearPendingException(my_cx);
}
} }
JSAutoRequest transfer(my_cx);
// Don't resolve standard classes on XPCNativeWrapper etc, only
// resolve them if we're resolving on the real global object.
ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
if (!ok) { if (!ok) {
// Trust the JS engine (or the script security manager) to set JS_SetPendingException(cx, exn);
// the exception in the JS engine. *_retval = JS_FALSE;
return NS_OK;
if (!JS_GetPendingException(my_cx, &exn)) {
return NS_ERROR_UNEXPECTED;
}
// Return NS_OK to avoid stomping over the exception that was passed
// down from the ResolveStandardClass call.
// Note that the order of the JS_ClearPendingException and
// JS_SetPendingException is important in the case that my_cx == cx.
JS_ClearPendingException(my_cx);
} }
}
if (!ok) { if (did_resolve) {
JS_SetPendingException(cx, exn); *objp = obj;
*_retval = JS_FALSE; return NS_OK;
return NS_OK; }
}
if (did_resolve) {
*objp = obj;
return NS_OK;
} }
if (!(flags & JSRESOLVE_ASSIGNING)) { if (!(flags & JSRESOLVE_ASSIGNING)) {
@ -7165,6 +7130,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK; return NS_OK;
} }
nsresult rv = NS_OK;
if (sLocation_id == id) { if (sLocation_id == id) {
// This must be done even if we're just getting the value of // This must be done even if we're just getting the value of
// window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING // window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
@ -7306,36 +7272,6 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
} }
} }
if (s_content_id == id) {
// Map window._content to window.content for backwards
// compatibility, this should spit out an message on the JS
// console.
JSObject *windowObj = win->GetGlobalJSObject();
JSAutoRequest ar(cx);
JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
windowObj, "_content");
if (!fun) {
return NS_ERROR_OUT_OF_MEMORY;
}
JSObject *funObj = ::JS_GetFunctionObject(fun);
if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
nullptr,
JSPROP_ENUMERATE | JSPROP_GETTER |
JSPROP_SHARED)) {
return NS_ERROR_FAILURE;
}
*objp = obj;
return NS_OK;
}
if (flags & JSRESOLVE_ASSIGNING) { if (flags & JSRESOLVE_ASSIGNING) {
if (IsReadonlyReplaceable(id) || if (IsReadonlyReplaceable(id) ||
(!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) { (!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) {
@ -9065,15 +9001,16 @@ GetDocumentAllHelper(JSObject *obj)
static inline void * static inline void *
FlagsToPrivate(PRUint32 flags) FlagsToPrivate(PRUint32 flags)
{ {
JS_ASSERT((flags & (1 << 31)) == 0); MOZ_ASSERT((flags & (1 << 31)) == 0);
return (void *)(flags << 1); return reinterpret_cast<void*>(static_cast<uintptr_t>(flags << 1));
} }
static inline PRUint32 static inline PRUint32
PrivateToFlags(void *priv) PrivateToFlags(void *priv)
{ {
JS_ASSERT(size_t(priv) <= PR_UINT32_MAX && (size_t(priv) & 1) == 0); uintptr_t intPriv = reinterpret_cast<uintptr_t>(priv);
return (PRUint32)(size_t(priv) >> 1); MOZ_ASSERT(intPriv <= PR_UINT32_MAX && (intPriv & 1) == 0);
return static_cast<PRUint32>(intPriv >> 1);
} }
JSBool JSBool
@ -9578,14 +9515,18 @@ nsHTMLSelectElementSH::SetOption(JSContext *cx, JS::Value *vp, PRUint32 aIndex,
JSAutoRequest ar(cx); JSAutoRequest ar(cx);
// vp must refer to an object // vp must refer to an object
if (!vp->isObject()) { if (!vp->isObjectOrNull()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
nsCOMPtr<nsIDOMHTMLOptionElement> new_option = do_QueryWrapper(cx, &vp->toObject()); nsCOMPtr<nsIDOMHTMLOptionElement> new_option;
if (!new_option) {
// Someone is trying to set an option to a non-option object. if (JSObject* obj = vp->toObjectOrNull()) {
return NS_ERROR_UNEXPECTED; new_option = do_QueryWrapper(cx, obj);
if (!new_option) {
// Someone is trying to set an option to a non-option object.
return NS_ERROR_UNEXPECTED;
}
} }
return aOptCollection->SetOption(aIndex, new_option); return aOptCollection->SetOption(aIndex, new_option);

View File

@ -157,7 +157,6 @@ protected:
} }
static nsresult Init(); static nsresult Init();
static nsresult RegisterClassName(PRInt32 aDOMClassInfoID);
static nsresult RegisterClassProtos(PRInt32 aDOMClassInfoID); static nsresult RegisterClassProtos(PRInt32 aDOMClassInfoID);
static nsresult RegisterExternalClasses(); static nsresult RegisterExternalClasses();
nsresult ResolveConstructor(JSContext *cx, JSObject *obj, nsresult ResolveConstructor(JSContext *cx, JSObject *obj,

View File

@ -41,6 +41,14 @@ nsDOMNavigationTiming::Clear()
mDOMContentLoadedEventEnd = 0; mDOMContentLoadedEventEnd = 0;
mDOMComplete = 0; mDOMComplete = 0;
mRedirectCheck = NOT_CHECKED; mRedirectCheck = NOT_CHECKED;
mLoadEventStartSet = false;
mLoadEventEndSet = false;
mDOMLoadingSet = false;
mDOMInteractiveSet = false;
mDOMContentLoadedEventStartSet = false;
mDOMContentLoadedEventEndSet = false;
mDOMCompleteSet = false;
} }
DOMTimeMilliSec DOMTimeMilliSec
@ -128,13 +136,19 @@ nsDOMNavigationTiming::NotifyUnloadEventEnd()
void void
nsDOMNavigationTiming::NotifyLoadEventStart() nsDOMNavigationTiming::NotifyLoadEventStart()
{ {
mLoadEventStart = DurationFromStart(); if (!mLoadEventStartSet) {
mLoadEventStart = DurationFromStart();
mLoadEventStartSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyLoadEventEnd() nsDOMNavigationTiming::NotifyLoadEventEnd()
{ {
mLoadEventEnd = DurationFromStart(); if (!mLoadEventEndSet) {
mLoadEventEnd = DurationFromStart();
mLoadEventEndSet = true;
}
} }
bool bool
@ -166,43 +180,61 @@ nsDOMNavigationTiming::ReportRedirects()
void void
nsDOMNavigationTiming::SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue) nsDOMNavigationTiming::SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue)
{ {
mLoadedURI = aURI; if (!mDOMLoadingSet) {
mDOMLoading = TimeStampToDOM(aValue); mLoadedURI = aURI;
mDOMLoading = TimeStampToDOM(aValue);
mDOMLoadingSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyDOMLoading(nsIURI* aURI) nsDOMNavigationTiming::NotifyDOMLoading(nsIURI* aURI)
{ {
mLoadedURI = aURI; if (!mDOMLoadingSet) {
mDOMLoading = DurationFromStart(); mLoadedURI = aURI;
mDOMLoading = DurationFromStart();
mDOMLoadingSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI) nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI)
{ {
mLoadedURI = aURI; if (!mDOMInteractiveSet) {
mDOMInteractive = DurationFromStart(); mLoadedURI = aURI;
mDOMInteractive = DurationFromStart();
mDOMInteractiveSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI) nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI)
{ {
mLoadedURI = aURI; if (!mDOMCompleteSet) {
mDOMComplete = DurationFromStart(); mLoadedURI = aURI;
mDOMComplete = DurationFromStart();
mDOMCompleteSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI) nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI)
{ {
mLoadedURI = aURI; if (!mDOMContentLoadedEventStartSet) {
mDOMContentLoadedEventStart = DurationFromStart(); mLoadedURI = aURI;
mDOMContentLoadedEventStart = DurationFromStart();
mDOMContentLoadedEventStartSet = true;
}
} }
void void
nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI) nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI)
{ {
mLoadedURI = aURI; if (!mDOMContentLoadedEventEndSet) {
mDOMContentLoadedEventEnd = DurationFromStart(); mLoadedURI = aURI;
mDOMContentLoadedEventEnd = DurationFromStart();
mDOMContentLoadedEventEndSet = true;
}
} }
PRUint16 PRUint16

View File

@ -136,6 +136,17 @@ private:
DOMTimeMilliSec mDOMContentLoadedEventStart; DOMTimeMilliSec mDOMContentLoadedEventStart;
DOMTimeMilliSec mDOMContentLoadedEventEnd; DOMTimeMilliSec mDOMContentLoadedEventEnd;
DOMTimeMilliSec mDOMComplete; DOMTimeMilliSec mDOMComplete;
// Booleans to keep track of what things we've already been notified
// about. We don't update those once we've been notified about them
// once.
bool mLoadEventStartSet : 1;
bool mLoadEventEndSet : 1;
bool mDOMLoadingSet : 1;
bool mDOMInteractiveSet : 1;
bool mDOMContentLoadedEventStartSet : 1;
bool mDOMContentLoadedEventEndSet : 1;
bool mDOMCompleteSet : 1;
}; };
#endif /* nsDOMNavigationTiming_h___ */ #endif /* nsDOMNavigationTiming_h___ */

View File

@ -1006,7 +1006,7 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType,
float aX, float aX,
float aY, float aY,
PRUint32 aDirection, PRUint32 aDirection,
PRFloat64 aDelta, double aDelta,
PRInt32 aModifiers, PRInt32 aModifiers,
PRUint32 aClickCount) PRUint32 aClickCount)
{ {

View File

@ -1956,6 +1956,17 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
if (newInnerWindow->mNavigator) { if (newInnerWindow->mNavigator) {
newInnerWindow->mNavigator->SetWindow(newInnerWindow); newInnerWindow->mNavigator->SetWindow(newInnerWindow);
} }
// Make a copy of the old window's performance object on document.open.
// Note that we have to force eager creation of it here, because we need
// to grab the current document channel and whatnot before that changes.
currentInner->CreatePerformanceObjectIfNeeded();
if (currentInner->mPerformance) {
newInnerWindow->mPerformance =
new nsPerformance(newInnerWindow,
currentInner->mPerformance->GetDOMTiming(),
currentInner->mPerformance->GetChannel());
}
} }
// Don't free objects on our current inner window if it's going to be // Don't free objects on our current inner window if it's going to be
@ -2931,27 +2942,31 @@ nsGlobalWindow::GetPerformance(nsISupports** aPerformance)
*aPerformance = nullptr; *aPerformance = nullptr;
if (nsGlobalWindow::HasPerformanceSupport()) { if (nsGlobalWindow::HasPerformanceSupport()) {
if (!mPerformance) { CreatePerformanceObjectIfNeeded();
if (!mDoc) {
return NS_OK;
}
nsRefPtr<nsDOMNavigationTiming> timing = mDoc->GetNavigationTiming();
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(mDoc->GetChannel()));
bool timingEnabled = false;
if (!timedChannel ||
!NS_SUCCEEDED(timedChannel->GetTimingEnabled(&timingEnabled)) ||
!timingEnabled) {
timedChannel = nullptr;
}
if (timing) {
mPerformance = new nsPerformance(this, timing, timedChannel);
}
}
NS_IF_ADDREF(*aPerformance = mPerformance); NS_IF_ADDREF(*aPerformance = mPerformance);
} }
return NS_OK; return NS_OK;
} }
void
nsGlobalWindow::CreatePerformanceObjectIfNeeded()
{
if (mPerformance || !mDoc) {
return;
}
nsRefPtr<nsDOMNavigationTiming> timing = mDoc->GetNavigationTiming();
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(mDoc->GetChannel()));
bool timingEnabled = false;
if (!timedChannel ||
!NS_SUCCEEDED(timedChannel->GetTimingEnabled(&timingEnabled)) ||
!timingEnabled) {
timedChannel = nullptr;
}
if (timing) {
mPerformance = new nsPerformance(this, timing, timedChannel);
}
}
/** /**
* GetScriptableParent is called when script reads window.parent. * GetScriptableParent is called when script reads window.parent.
* *
@ -3070,6 +3085,14 @@ nsGlobalWindow::GetTopImpl(nsIDOMWindow** aTop, bool aScriptable)
return NS_OK; return NS_OK;
} }
// Map window._content to window.content for backwards compatibility, this
// should spit out an message on the JS console.
NS_IMETHODIMP
nsGlobalWindow::GetContentForCompat(nsIDOMWindow** aContent)
{
return GetContent(aContent);
}
NS_IMETHODIMP NS_IMETHODIMP
nsGlobalWindow::GetContent(nsIDOMWindow** aContent) nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
{ {
@ -3114,7 +3137,7 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
} }
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(primaryContent)); nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(primaryContent));
NS_IF_ADDREF(*aContent = domWindow); domWindow.forget(aContent);
return NS_OK; return NS_OK;
} }

View File

@ -905,6 +905,9 @@ protected:
// Implements Get{Real,Scriptable}Top. // Implements Get{Real,Scriptable}Top.
nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable); nsresult GetTopImpl(nsIDOMWindow **aWindow, bool aScriptable);
// Helper for creating performance objects.
void CreatePerformanceObjectIfNeeded();
// When adding new member variables, be careful not to create cycles // When adding new member variables, be careful not to create cycles
// through JavaScript. If there is any chance that a member variable // through JavaScript. If there is any chance that a member variable
// could own objects that are implemented in JavaScript, then those // could own objects that are implemented in JavaScript, then those
@ -990,6 +993,7 @@ protected:
nsCOMPtr<nsIPrincipal> mArgumentsOrigin; nsCOMPtr<nsIPrincipal> mArgumentsOrigin;
nsRefPtr<Navigator> mNavigator; nsRefPtr<Navigator> mNavigator;
nsRefPtr<nsScreen> mScreen; nsRefPtr<nsScreen> mScreen;
// mPerformance is only used on inner windows.
nsRefPtr<nsPerformance> mPerformance; nsRefPtr<nsPerformance> mPerformance;
nsRefPtr<nsDOMWindowList> mFrames; nsRefPtr<nsDOMWindowList> mFrames;
nsRefPtr<nsBarProp> mMenubar; nsRefPtr<nsBarProp> mMenubar;

View File

@ -140,6 +140,11 @@ public:
return mDOMTiming; return mDOMTiming;
} }
nsITimedChannel* GetChannel() const
{
return mChannel;
}
nsIDOMWindow* GetParentObject() const nsIDOMWindow* GetParentObject() const
{ {
return mWindow.get(); return mWindow.get();

View File

@ -64,7 +64,7 @@ struct TypedArray : public TypedArray_base<T,UnboxArray> {
static inline JSObject* static inline JSObject*
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length, Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
T* data = NULL) { const T* data = NULL) {
JSObject* creatorWrapper; JSObject* creatorWrapper;
JSAutoEnterCompartment ac; JSAutoEnterCompartment ac;
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) { if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {

View File

@ -62,14 +62,18 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper)
BluetoothAdapter::BluetoothAdapter(nsPIDOMWindow* aOwner, const nsAString& aPath) BluetoothAdapter::BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue)
: BluetoothPropertyContainer(BluetoothObjectType::TYPE_ADAPTER) : BluetoothPropertyContainer(BluetoothObjectType::TYPE_ADAPTER)
, mJsUuids(nullptr) , mJsUuids(nullptr)
, mJsDeviceAddresses(nullptr) , mJsDeviceAddresses(nullptr)
, mIsRooted(false) , mIsRooted(false)
{ {
BindToOwner(aOwner); BindToOwner(aOwner);
mPath = aPath; const InfallibleTArray<BluetoothNamedValue>& values =
aValue.get_ArrayOfBluetoothNamedValue();
for (uint32_t i = 0; i < values.Length(); ++i) {
SetPropertyByValue(values[i]);
}
} }
BluetoothAdapter::~BluetoothAdapter() BluetoothAdapter::~BluetoothAdapter()
@ -175,21 +179,16 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
// static // static
already_AddRefed<BluetoothAdapter> already_AddRefed<BluetoothAdapter>
BluetoothAdapter::Create(nsPIDOMWindow* aOwner, const nsAString& aPath) BluetoothAdapter::Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue)
{ {
// Make sure we at least have a path
NS_ASSERTION(!aPath.IsEmpty(), "Adapter created with empty path!");
BluetoothService* bs = BluetoothService::Get(); BluetoothService* bs = BluetoothService::Get();
if (!bs) { if (!bs) {
NS_WARNING("BluetoothService not available!"); NS_WARNING("BluetoothService not available!");
return nullptr; return nullptr;
} }
nsRefPtr<BluetoothAdapter> adapter = new BluetoothAdapter(aOwner, aPath); nsRefPtr<BluetoothAdapter> adapter = new BluetoothAdapter(aOwner, aValue);
nsString path; if (NS_FAILED(bs->RegisterBluetoothSignalHandler(adapter->GetPath(), adapter))) {
path = adapter->GetPath();
if (NS_FAILED(bs->RegisterBluetoothSignalHandler(path, adapter))) {
NS_WARNING("Failed to register object with observer!"); NS_WARNING("Failed to register object with observer!");
return nullptr; return nullptr;
} }

View File

@ -20,6 +20,7 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothSignal; class BluetoothSignal;
class BluetoothNamedValue; class BluetoothNamedValue;
class BluetoothValue;
class BluetoothAdapter : public nsDOMEventTargetHelper class BluetoothAdapter : public nsDOMEventTargetHelper
, public nsIDOMBluetoothAdapter , public nsIDOMBluetoothAdapter
@ -36,7 +37,7 @@ public:
nsDOMEventTargetHelper) nsDOMEventTargetHelper)
static already_AddRefed<BluetoothAdapter> static already_AddRefed<BluetoothAdapter>
Create(nsPIDOMWindow* aOwner, const nsAString& name); Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
void Notify(const BluetoothSignal& aParam); void Notify(const BluetoothSignal& aParam);
@ -57,7 +58,7 @@ public:
virtual void SetPropertyByValue(const BluetoothNamedValue& aValue); virtual void SetPropertyByValue(const BluetoothNamedValue& aValue);
private: private:
BluetoothAdapter(nsPIDOMWindow* aOwner, const nsAString& aPath); BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
~BluetoothAdapter(); ~BluetoothAdapter();
void Root(); void Root();

Some files were not shown because too many files have changed in this diff Show More