mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Merge services-central with mozilla-central
This commit is contained in:
commit
8ffd862722
@ -352,12 +352,15 @@ nsCaretAccessible::GetCaretRect(nsIWidget **aOutWidget)
|
||||
}
|
||||
|
||||
nsPoint offset;
|
||||
// Offset from widget origin to the frame origin, which includes chrome
|
||||
// on the widget.
|
||||
*aOutWidget = frame->GetNearestWidget(offset);
|
||||
NS_ENSURE_TRUE(*aOutWidget, nsIntRect());
|
||||
rect.MoveBy(offset);
|
||||
|
||||
caretRect = rect.ToOutsidePixels(frame->PresContext()->AppUnitsPerDevPixel());
|
||||
caretRect.MoveBy((*aOutWidget)->WidgetToScreenOffset());
|
||||
// ((content screen origin) - (content offset in the widget)) = widget origin on the screen
|
||||
caretRect.MoveBy((*aOutWidget)->WidgetToScreenOffset() - (*aOutWidget)->GetClientOffset());
|
||||
|
||||
// Correct for character size, so that caret always matches the size of the character
|
||||
// This is important for font size transitions, and is necessary because the Gecko caret uses the
|
||||
|
@ -35,6 +35,9 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define CreateEvent CreateEventA
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
#include "States.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsApplicationAccessibleWrap.h"
|
||||
@ -48,7 +51,6 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeNode.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
@ -76,11 +78,8 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsRootAccessible.h"
|
||||
#include "nsIDOMNSEventTarget.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULTreeAccessible.h"
|
||||
@ -415,10 +414,10 @@ nsRootAccessible::FireCurrentFocusEvent()
|
||||
return; // No current focus
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(mDocument);
|
||||
if (docEvent) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mDocument);
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
if (NS_SUCCEEDED(docEvent->CreateEvent(NS_LITERAL_STRING("Events"),
|
||||
if (NS_SUCCEEDED(domDoc->CreateEvent(NS_LITERAL_STRING("Events"),
|
||||
getter_AddRefs(event))) &&
|
||||
NS_SUCCEEDED(event->InitEvent(NS_LITERAL_STRING("focus"), PR_TRUE, PR_TRUE))) {
|
||||
|
||||
|
@ -102,51 +102,20 @@ CPPSRCS = nsBrowserApp.cpp
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
ifdef _MSC_VER
|
||||
STATIC_COMPONENTS_LINKER_PATH = -LIBPATH:$(DEPTH)/staticlib
|
||||
else
|
||||
STATIC_COMPONENTS_LINKER_PATH = -L$(DEPTH)/staticlib
|
||||
endif
|
||||
LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX)
|
||||
else
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
LIBS += $(DIST)/bin/XUL
|
||||
TK_LIBS := $(TK_LIBS)
|
||||
else
|
||||
EXTRA_DSO_LIBS += xul
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
TK_LIBS := $(TK_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS)
|
||||
else
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
APP_XPCOM_LIBS = $(XPCOM_LIBS)
|
||||
endif
|
||||
|
||||
LIBS += \
|
||||
$(STATIC_COMPONENTS_LINKER_PATH) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(APP_XPCOM_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
LIBS += \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
# Add explicit X11 dependency when building against X11 toolkits
|
||||
ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
LIBS += $(XLDFLAGS) $(XLIBS) $(ZLIB_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_JPROF
|
||||
LIBS += -ljprof
|
||||
endif
|
||||
@ -171,18 +140,6 @@ ifdef _MSC_VER
|
||||
WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
|
||||
endif
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
include $(topsrcdir)/config/static-config.mk
|
||||
|
||||
EXTRA_DEPS += \
|
||||
$(STATIC_EXTRA_DEPS) \
|
||||
$(NULL)
|
||||
DEFINES += $(STATIC_DEFINES)
|
||||
CPPSRCS += $(STATIC_CPPSRCS)
|
||||
EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS)
|
||||
EXTRA_LIBS += $(STATIC_EXTRA_LIBS)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool)
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,usp10 msimg32)
|
||||
@ -195,9 +152,6 @@ RCFLAGS += -DMOZ_PHOENIX -I$(srcdir)
|
||||
else
|
||||
RCFLAGS += -DMOZ_PHOENIX --include-dir $(srcdir)
|
||||
endif
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
RCFLAGS += -DMOZ_STATIC_BUILD
|
||||
endif
|
||||
ifdef DEBUG
|
||||
RCFLAGS += -DDEBUG
|
||||
endif
|
||||
@ -206,9 +160,6 @@ endif
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
RESFILE=splashos2.res
|
||||
RCFLAGS += -DMOZ_PHOENIX
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
RCFLAGS += -DMOZ_STATIC_BUILD -i $(DIST)/include
|
||||
endif
|
||||
ifdef DEBUG
|
||||
RCFLAGS += -DDEBUG
|
||||
endif
|
||||
@ -217,12 +168,6 @@ endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
include $(topsrcdir)/config/static-rules.mk
|
||||
|
||||
DEFINES += -DIMPL_XREAPI
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),photon)
|
||||
LIBS += -lphexlib
|
||||
endif
|
||||
|
@ -91,6 +91,9 @@ function onBuiltinSurveyLoad() {
|
||||
explanation.innerHTML = "";
|
||||
}
|
||||
drawSurveyForm(task, contentDiv);
|
||||
// Allow surveys to define arbitrary page load handlers - call them
|
||||
// after creating the rest of the page:
|
||||
task.onPageLoad(task, document);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +117,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
for (let i = 0; i < surveyQuestions.length; i++) {
|
||||
let question = surveyQuestions[i].question;
|
||||
let explanation = surveyQuestions[i].explanation;
|
||||
let elem;
|
||||
let elem, j;
|
||||
|
||||
elem = document.createElement("h3");
|
||||
elem.innerHTML = (i+1) + ". " + question;
|
||||
@ -129,7 +132,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
let choices = surveyQuestions[i].choices;
|
||||
switch (surveyQuestions[i].type) {
|
||||
case MULTIPLE_CHOICE:
|
||||
for (let j = 0; j < choices.length; j++) {
|
||||
for (j = 0; j < choices.length; j++) {
|
||||
let newRadio = document.createElement("input");
|
||||
newRadio.setAttribute("type", "radio");
|
||||
newRadio.setAttribute("name", "answer_to_" + i);
|
||||
@ -148,7 +151,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
case CHECK_BOXES_WITH_FREE_ENTRY:
|
||||
let checkboxName = "answer_to_" + i;
|
||||
// Check boxes:
|
||||
for (let j = 0; j < choices.length; j++) {
|
||||
for (j = 0; j < choices.length; j++) {
|
||||
let newCheck = document.createElement("input");
|
||||
newCheck.setAttribute("type", "checkbox");
|
||||
newCheck.setAttribute("name", checkboxName);
|
||||
@ -188,7 +191,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
inputBox.addEventListener(
|
||||
"keypress", function() {
|
||||
let elements = document.getElementsByName(checkboxName);
|
||||
for (let j = (elements.length - 1); j >= 0; j--) {
|
||||
for (j = (elements.length - 1); j >= 0; j--) {
|
||||
if (elements[j].value == freeformId) {
|
||||
elements[j].checked = true;
|
||||
break;
|
||||
@ -213,7 +216,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
let label = document.createElement("span");
|
||||
label.innerHTML = surveyQuestions[i].min_label;
|
||||
contentDiv.appendChild(label);
|
||||
for (let j = surveyQuestions[i].scale_minimum;
|
||||
for (j = surveyQuestions[i].scale_minimum;
|
||||
j <= surveyQuestions[i].scale_maximum;
|
||||
j++) {
|
||||
let newRadio = document.createElement("input");
|
||||
@ -243,7 +246,7 @@ function drawSurveyForm(task, contentDiv) {
|
||||
let freeformId = "freeform_" + i;
|
||||
let radioName = "answer_to_" + i;
|
||||
|
||||
for (let j = 0; j < choices.length; j++) {
|
||||
for (j = 0; j < choices.length; j++) {
|
||||
let newRadio = document.createElement("input");
|
||||
newRadio.setAttribute("type", "radio");
|
||||
newRadio.setAttribute("name", radioName);
|
||||
|
@ -520,7 +520,7 @@ exports.RemoteExperimentLoader.prototype = {
|
||||
e.fileName + ": " + e.message;
|
||||
this._loadErrors.push(errStr);
|
||||
this._logger.warn("Error loading " + filename);
|
||||
this._logger.warn(e);
|
||||
this._logger.warn(errStr);
|
||||
}
|
||||
}
|
||||
return remoteExperiments;
|
||||
|
@ -597,7 +597,7 @@ TestPilotExperiment.prototype = {
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
this._logger.warn("Error in getStudyMetadata: " + e);
|
||||
this._dataStore.logException("getStudyMetadata: " + e);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@ -660,6 +660,7 @@ TestPilotExperiment.prototype = {
|
||||
// This method handles all date-related status changes and should be
|
||||
// called periodically.
|
||||
let currentDate = this._now();
|
||||
let self = this;
|
||||
|
||||
// Reset automatically recurring tests:
|
||||
if (this._recursAutomatically &&
|
||||
@ -703,7 +704,6 @@ TestPilotExperiment.prototype = {
|
||||
currentDate <= this._endDate) {
|
||||
this._logger.info("Study now starting.");
|
||||
// clear the data before starting.
|
||||
let self = this;
|
||||
this._dataStore.wipeAllData(function() {
|
||||
// Experiment is now in progress.
|
||||
self.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true);
|
||||
@ -714,7 +714,6 @@ TestPilotExperiment.prototype = {
|
||||
// What happens when a test finishes:
|
||||
if (this._status < TaskConstants.STATUS_FINISHED &&
|
||||
currentDate > this._endDate) {
|
||||
let self = this;
|
||||
let setDataDeletionDate = true;
|
||||
this._logger.info("Passed End Date - Switched Task Status to Finished");
|
||||
this.changeStatus(TaskConstants.STATUS_FINISHED);
|
||||
@ -896,7 +895,6 @@ TestPilotExperiment.prototype = {
|
||||
optOut: function TestPilotExperiment_optOut(reason, callback) {
|
||||
// Regardless of study ID, post the opt-out message to a special
|
||||
// database table of just opt-out messages; include study ID in metadata.
|
||||
let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out";
|
||||
let logger = this._logger;
|
||||
|
||||
this.onExperimentShutdown();
|
||||
@ -909,6 +907,7 @@ TestPilotExperiment.prototype = {
|
||||
if (reason) {
|
||||
// Send us the reason...
|
||||
// (TODO: include metadata?)
|
||||
let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out";
|
||||
let answer = {id: this._id,
|
||||
reason: reason};
|
||||
let dataString = JSON.stringify(answer);
|
||||
@ -924,18 +923,24 @@ TestPilotExperiment.prototype = {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200 || req.status == 201 || req.status == 202) {
|
||||
logger.info("Quit reason posted successfully " + req.responseText);
|
||||
if (callback) {
|
||||
callback(true);
|
||||
}
|
||||
} else {
|
||||
logger.warn(req.status + " posting error " + req.responseText);
|
||||
if (callback) {
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
logger.trace("Sending quit reason.");
|
||||
req.send(dataString);
|
||||
} else {
|
||||
if (callback) {
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setRecurPref: function TPE_setRecurPrefs(value) {
|
||||
@ -961,6 +966,7 @@ TestPilotBuiltinSurvey.prototype = {
|
||||
this._versionNumber = surveyInfo.versionNumber;
|
||||
this._questions = surveyInfo.surveyQuestions;
|
||||
this._explanation = surveyInfo.surveyExplanation;
|
||||
this._onPageLoad = surveyInfo.onPageLoad;
|
||||
},
|
||||
|
||||
get taskType() {
|
||||
@ -988,6 +994,12 @@ TestPilotBuiltinSurvey.prototype = {
|
||||
return this._studyId;
|
||||
},
|
||||
|
||||
onPageLoad: function(task, document) {
|
||||
if (this._onPageLoad) {
|
||||
this._onPageLoad(task, document);
|
||||
}
|
||||
},
|
||||
|
||||
onDetailPageOpened: function TPS_onDetailPageOpened() {
|
||||
if (this._status < TaskConstants.STATUS_IN_PROGRESS) {
|
||||
this.changeStatus( TaskConstants.STATUS_IN_PROGRESS, true );
|
||||
|
@ -6698,12 +6698,15 @@ var gPluginHandler = {
|
||||
handleEvent : function(event) {
|
||||
let self = gPluginHandler;
|
||||
let plugin = event.target;
|
||||
let hideBarPrefName;
|
||||
let doc = plugin.ownerDocument;
|
||||
|
||||
// We're expecting the target to be a plugin.
|
||||
if (!(plugin instanceof Ci.nsIObjectLoadingContent))
|
||||
return;
|
||||
|
||||
// Force a style flush, so that we ensure our binding is attached.
|
||||
plugin.clientTop;
|
||||
|
||||
switch (event.type) {
|
||||
case "PluginCrashed":
|
||||
self.pluginInstanceCrashed(plugin, event);
|
||||
@ -6713,32 +6716,38 @@ var gPluginHandler = {
|
||||
// For non-object plugin tags, register a click handler to install the
|
||||
// plugin. Object tags can, and often do, deal with that themselves,
|
||||
// so don't stomp on the page developers toes.
|
||||
if (!(plugin instanceof HTMLObjectElement))
|
||||
self.addLinkClickCallback(plugin, "installSinglePlugin");
|
||||
if (!(plugin instanceof HTMLObjectElement)) {
|
||||
// We don't yet check to see if there's actually an installer available.
|
||||
let installStatus = doc.getAnonymousElementByAttribute(plugin, "class", "installStatus");
|
||||
installStatus.setAttribute("status", "ready");
|
||||
let iconStatus = doc.getAnonymousElementByAttribute(plugin, "class", "icon");
|
||||
iconStatus.setAttribute("status", "ready");
|
||||
|
||||
let installLink = doc.getAnonymousElementByAttribute(plugin, "class", "installPluginLink");
|
||||
self.addLinkClickCallback(installLink, "installSinglePlugin", plugin);
|
||||
}
|
||||
/* FALLTHRU */
|
||||
|
||||
case "PluginBlocklisted":
|
||||
case "PluginOutdated":
|
||||
hideBarPrefName = event.type == "PluginOutdated" ?
|
||||
"plugins.hide_infobar_for_outdated_plugin" :
|
||||
"plugins.hide_infobar_for_missing_plugin";
|
||||
if (gPrefService.getBoolPref(hideBarPrefName))
|
||||
return;
|
||||
|
||||
self.pluginUnavailable(plugin, event.type);
|
||||
break;
|
||||
#ifdef XP_MACOSX
|
||||
case "npapi-carbon-event-model-failure":
|
||||
hideBarPrefName = "plugins.hide_infobar_for_carbon_failure_plugin";
|
||||
if (gPrefService.getBoolPref(hideBarPrefName))
|
||||
return;
|
||||
|
||||
#endif
|
||||
self.pluginUnavailable(plugin, event.type);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case "PluginDisabled":
|
||||
self.addLinkClickCallback(plugin, "managePlugins");
|
||||
let manageLink = doc.getAnonymousElementByAttribute(plugin, "class", "managePluginsLink");
|
||||
self.addLinkClickCallback(manageLink, "managePlugins");
|
||||
break;
|
||||
}
|
||||
|
||||
// Hide the in-content UI if it's too big. The crashed plugin handler already did this.
|
||||
if (event.type != "PluginCrashed") {
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
||||
if (self.isTooSmall(plugin, overlay))
|
||||
overlay.style.visibility = "hidden";
|
||||
}
|
||||
},
|
||||
|
||||
newPluginInstalled : function(event) {
|
||||
@ -6757,10 +6766,10 @@ var gPluginHandler = {
|
||||
},
|
||||
|
||||
// Callback for user clicking on a missing (unsupported) plugin.
|
||||
installSinglePlugin: function (aEvent) {
|
||||
installSinglePlugin: function (plugin) {
|
||||
var missingPluginsArray = {};
|
||||
|
||||
var pluginInfo = getPluginInfo(aEvent.target);
|
||||
var pluginInfo = getPluginInfo(plugin);
|
||||
missingPluginsArray[pluginInfo.mimetype] = pluginInfo;
|
||||
|
||||
openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
|
||||
@ -6810,9 +6819,6 @@ var gPluginHandler = {
|
||||
let blockedNotification = notificationBox.getNotificationWithValue("blocked-plugins");
|
||||
let missingNotification = notificationBox.getNotificationWithValue("missing-plugins");
|
||||
|
||||
// If there is already an outdated plugin notification then do nothing
|
||||
if (outdatedNotification)
|
||||
return;
|
||||
|
||||
function showBlocklistInfo() {
|
||||
var url = formatURL("extensions.blocklist.detailsURL", true);
|
||||
@ -6908,8 +6914,15 @@ var gPluginHandler = {
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// If there is already an outdated plugin notification then do nothing
|
||||
if (outdatedNotification)
|
||||
return;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (eventType == "npapi-carbon-event-model-failure") {
|
||||
if (gPrefService.getBoolPref("plugins.hide_infobar_for_carbon_failure_plugin"))
|
||||
return;
|
||||
|
||||
let carbonFailureNotification =
|
||||
notificationBox.getNotificationWithValue("carbon-failure-plugins");
|
||||
@ -6923,11 +6936,18 @@ var gPluginHandler = {
|
||||
eventType = "PluginNotFound";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (eventType == "PluginBlocklisted") {
|
||||
if (gPrefService.getBoolPref("plugins.hide_infobar_for_missing_plugin")) // XXX add a new pref?
|
||||
return;
|
||||
|
||||
if (blockedNotification || missingNotification)
|
||||
return;
|
||||
}
|
||||
else if (eventType == "PluginOutdated") {
|
||||
if (gPrefService.getBoolPref("plugins.hide_infobar_for_outdated_plugin"))
|
||||
return;
|
||||
|
||||
// Cancel any notification about blocklisting/missing plugins
|
||||
if (blockedNotification)
|
||||
blockedNotification.close();
|
||||
@ -6935,6 +6955,9 @@ var gPluginHandler = {
|
||||
missingNotification.close();
|
||||
}
|
||||
else if (eventType == "PluginNotFound") {
|
||||
if (gPrefService.getBoolPref("plugins.hide_infobar_for_missing_plugin"))
|
||||
return;
|
||||
|
||||
if (missingNotification)
|
||||
return;
|
||||
|
||||
@ -6990,9 +7013,6 @@ var gPluginHandler = {
|
||||
// Remap the plugin name to a more user-presentable form.
|
||||
pluginName = this.makeNicePluginName(pluginName, pluginFilename);
|
||||
|
||||
// Force a style flush, so that we ensure our binding is attached.
|
||||
plugin.clientTop;
|
||||
|
||||
let messageString = gNavigatorBundle.getFormattedString("crashedpluginsMessage.title", [pluginName]);
|
||||
|
||||
//
|
||||
@ -7000,12 +7020,6 @@ var gPluginHandler = {
|
||||
//
|
||||
let doc = plugin.ownerDocument;
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
||||
|
||||
// The binding has role="link" here, since missing/disabled/blocked
|
||||
// plugin UI has a onclick handler on the whole thing. This isn't needed
|
||||
// for the plugin-crashed UI, because we use actual HTML links in the text.
|
||||
overlay.removeAttribute("role");
|
||||
|
||||
let statusDiv = doc.getAnonymousElementByAttribute(plugin, "class", "submitStatus");
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
let status;
|
||||
@ -7659,12 +7673,6 @@ var gIdentityHandler = {
|
||||
icon_label = this.getEffectiveHost();
|
||||
}
|
||||
|
||||
// We need a port number for all lookups. If one hasn't been specified, use
|
||||
// the https default
|
||||
var lookupHost = this._lastLocation.host;
|
||||
if (lookupHost.indexOf(':') < 0)
|
||||
lookupHost += ":443";
|
||||
|
||||
// Verifier is either the CA Org, for a normal cert, or a special string
|
||||
// for certs that are trusted because of a security exception.
|
||||
var tooltip = gNavigatorBundle.getFormattedString("identity.identified.verifier",
|
||||
@ -7674,7 +7682,12 @@ var gIdentityHandler = {
|
||||
// thing here in terms of converting _lastLocation.port from string to int, but
|
||||
// the overrideService doesn't like undefined ports, so make sure we have
|
||||
// something in the default case (bug 432241).
|
||||
if (this._overrideService.hasMatchingOverride(this._lastLocation.hostname,
|
||||
// .hostname can return an empty string in some exceptional cases -
|
||||
// hasMatchingOverride does not handle that, so avoid calling it.
|
||||
// Updating the tooltip value in those cases isn't critical.
|
||||
// FIXME: Fixing bug 646690 would probably makes this check unnecessary
|
||||
if (this._lastLocation.hostname &&
|
||||
this._overrideService.hasMatchingOverride(this._lastLocation.hostname,
|
||||
(this._lastLocation.port || 443),
|
||||
iData.cert, {}, {}))
|
||||
tooltip = gNavigatorBundle.getString("identity.identified.verified_by_you");
|
||||
|
@ -112,7 +112,7 @@ _BROWSER_FILES = \
|
||||
browser_bug416661.js \
|
||||
browser_bug417483.js \
|
||||
browser_bug419612.js \
|
||||
browser_bug420160.js \
|
||||
browser_identity_UI.js \
|
||||
browser_bug422590.js \
|
||||
browser_bug424101.js \
|
||||
browser_bug427559.js \
|
||||
|
@ -1,53 +0,0 @@
|
||||
var listener = {
|
||||
testFunction: null,
|
||||
|
||||
handleEvent: function (e) {
|
||||
this.testFunction();
|
||||
}
|
||||
}
|
||||
|
||||
/* Tests for correct behaviour of getEffectiveHost on identity handler */
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
ok(gIdentityHandler, "gIdentityHandler should exist");
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", listener, true);
|
||||
listener.testFunction = testNormalDomain;
|
||||
content.location = "http://test1.example.org/";
|
||||
}
|
||||
|
||||
// Greek IDN for 'example.test'.
|
||||
var idnDomain = "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE";
|
||||
|
||||
function testNormalDomain() {
|
||||
is(gIdentityHandler._lastLocation.host, 'test1.example.org', "Identity handler is getting the full location");
|
||||
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for test1.example.org");
|
||||
|
||||
listener.testFunction = testIDNDomain;
|
||||
content.location = "http://sub1." + idnDomain + "/";
|
||||
}
|
||||
|
||||
function testIDNDomain() {
|
||||
is(gIdentityHandler._lastLocation.host, "sub1." + idnDomain, "Identity handler is getting the full location");
|
||||
is(gIdentityHandler.getEffectiveHost(), idnDomain, "getEffectiveHost should return the IDN base domain in UTF-8");
|
||||
|
||||
listener.testFunction = testNormalDomainWithPort;
|
||||
content.location = "http://sub1.test1.example.org:8000/";
|
||||
}
|
||||
|
||||
function testNormalDomainWithPort() {
|
||||
is(gIdentityHandler._lastLocation.host, 'sub1.test1.example.org:8000', "Identity handler is getting port information");
|
||||
is(gIdentityHandler.getEffectiveHost(), 'example.org', "getEffectiveHost should return example.org for sub1.test1.example.org:8000");
|
||||
|
||||
listener.testFunction = testIPWithPort;
|
||||
content.location = "http://127.0.0.1:8888/";
|
||||
}
|
||||
|
||||
function testIPWithPort() {
|
||||
is(gIdentityHandler.getEffectiveHost(), '127.0.0.1', "getEffectiveHost should return 127.0.0.1 for 127.0.0.1:8888");
|
||||
gBrowser.selectedBrowser.removeEventListener("load", listener, true);
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
113
browser/base/content/test/browser_identity_UI.js
Normal file
113
browser/base/content/test/browser_identity_UI.js
Normal file
@ -0,0 +1,113 @@
|
||||
/* Tests for correct behaviour of getEffectiveHost on identity handler */
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
ok(gIdentityHandler, "gIdentityHandler should exist");
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", checkResult, true);
|
||||
|
||||
nextTest();
|
||||
}
|
||||
|
||||
// Greek IDN for 'example.test'.
|
||||
var idnDomain = "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE";
|
||||
var tests = [
|
||||
{
|
||||
name: "normal domain",
|
||||
location: "http://test1.example.org/",
|
||||
host: "test1.example.org",
|
||||
effectiveHost: "example.org"
|
||||
},
|
||||
{
|
||||
name: "view-source",
|
||||
location: "view-source:http://example.com/",
|
||||
// TODO: these should not be blank, bug 646690
|
||||
host: "",
|
||||
effectiveHost: ""
|
||||
},
|
||||
{
|
||||
name: "normal HTTPS",
|
||||
location: "https://example.com/",
|
||||
host: "example.com",
|
||||
effectiveHost: "example.com",
|
||||
isHTTPS: true
|
||||
},
|
||||
{
|
||||
name: "IDN subdomain",
|
||||
location: "http://sub1." + idnDomain + "/",
|
||||
host: "sub1." + idnDomain,
|
||||
effectiveHost: idnDomain
|
||||
},
|
||||
{
|
||||
name: "subdomain with port",
|
||||
location: "http://sub1.test1.example.org:8000/",
|
||||
host: "sub1.test1.example.org:8000",
|
||||
effectiveHost: "example.org"
|
||||
},
|
||||
{
|
||||
name: "subdomain HTTPS",
|
||||
location: "https://test1.example.com",
|
||||
host: "test1.example.com",
|
||||
effectiveHost: "example.com",
|
||||
isHTTPS: true
|
||||
},
|
||||
{
|
||||
name: "view-source HTTPS",
|
||||
location: "view-source:https://example.com/",
|
||||
// TODO: these should not be blank, bug 646690
|
||||
host: "",
|
||||
effectiveHost: "",
|
||||
isHTTPS: true
|
||||
},
|
||||
{
|
||||
name: "IP address",
|
||||
location: "http://127.0.0.1:8888/",
|
||||
host: "127.0.0.1:8888",
|
||||
effectiveHost: "127.0.0.1"
|
||||
},
|
||||
]
|
||||
|
||||
let gCurrentTest, gCurrentTestIndex = -1;
|
||||
// Go through the tests in both directions, to add additional coverage for
|
||||
// transitions between different states.
|
||||
let gForward = true;
|
||||
function nextTest() {
|
||||
if (gForward)
|
||||
gCurrentTestIndex++;
|
||||
else
|
||||
gCurrentTestIndex--;
|
||||
|
||||
if (gCurrentTestIndex == tests.length) {
|
||||
// Went too far, reverse
|
||||
gCurrentTestIndex--;
|
||||
gForward = false;
|
||||
}
|
||||
|
||||
if (gCurrentTestIndex == -1) {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", checkResult, true);
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
gCurrentTest = tests[gCurrentTestIndex];
|
||||
gTestDesc = "#" + gCurrentTestIndex + " (" + gCurrentTest.name + ")";
|
||||
if (!gForward)
|
||||
gTestDesc += " (second time)";
|
||||
content.location = gCurrentTest.location;
|
||||
}
|
||||
|
||||
function checkResult() {
|
||||
if (gCurrentTest.isHTTPS) {
|
||||
// Check that the effective host is displayed in the UI
|
||||
let label = document.getElementById("identity-icon-label");
|
||||
is(label.value, gCurrentTest.effectiveHost, "effective host is displayed in identity icon label for test " + gTestDesc);
|
||||
}
|
||||
|
||||
// Sanity check other values, and the value of gIdentityHandler.getEffectiveHost()
|
||||
is(gIdentityHandler._lastLocation.host, gCurrentTest.host, "host matches for test " + gTestDesc);
|
||||
is(gIdentityHandler.getEffectiveHost(), gCurrentTest.effectiveHost, "effectiveHost matches for test " + gTestDesc);
|
||||
|
||||
executeSoon(nextTest);
|
||||
}
|
@ -9,30 +9,46 @@ function test() {
|
||||
|
||||
let urls = [
|
||||
"javascript:'foopy';",
|
||||
"data:text/html,<script>document.write(document.domain);</script>"
|
||||
"data:text/html,<body>hi"
|
||||
];
|
||||
|
||||
function urlEnter(url) {
|
||||
gURLBar.value = url;
|
||||
gURLBar.focus();
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
}
|
||||
|
||||
function urlClick(url) {
|
||||
gURLBar.value = url;
|
||||
gURLBar.focus();
|
||||
let goButton = document.getElementById("urlbar-go-button");
|
||||
EventUtils.synthesizeMouseAtCenter(goButton, {});
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
let url = urls.shift();
|
||||
if (url)
|
||||
testURL(url, nextTest);
|
||||
if (url) {
|
||||
testURL(url, urlEnter, function () {
|
||||
testURL(url, urlClick, nextTest);
|
||||
});
|
||||
}
|
||||
else
|
||||
finish();
|
||||
}
|
||||
|
||||
function testURL(newURL, func) {
|
||||
function testURL(url, loadFunc, endFunc) {
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
registerCleanupFunction(function () {
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
addPageShowListener(function () {
|
||||
let pagePrincipal = gBrowser.contentPrincipal;
|
||||
gURLBar.value = newURL;
|
||||
gURLBar.handleCommand();
|
||||
loadFunc(url);
|
||||
|
||||
addPageShowListener(function () {
|
||||
ok(!gBrowser.contentPrincipal.equals(pagePrincipal), "load of " + newURL + " produced a page with a different principal");
|
||||
func();
|
||||
ok(!gBrowser.contentPrincipal.equals(pagePrincipal),
|
||||
"load of " + url + " by " + loadFunc.name + " should produce a page with a different principal");
|
||||
endFunc();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -127,7 +127,12 @@ function test3() {
|
||||
|
||||
new TabOpenListener("about:addons", test4, prepareTest5);
|
||||
|
||||
EventUtils.synthesizeMouse(gTestBrowser.contentDocument.getElementById("test"),
|
||||
var pluginNode = gTestBrowser.contentDocument.getElementById("test");
|
||||
ok(pluginNode, "Test 3, Found plugin in page");
|
||||
var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "class", "managePluginsLink");
|
||||
ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding");
|
||||
|
||||
EventUtils.synthesizeMouse(manageLink,
|
||||
5, 5, {}, gTestBrowser.contentWindow);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
<embed id="test" style="width: 100px; height: 100px" type="application/x-test">
|
||||
<embed id="test" style="width: 200px; height: 200px" type="application/x-test">
|
||||
</body>
|
||||
</html>
|
||||
|
@ -292,16 +292,26 @@
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
|
||||
function loadCurrent() {
|
||||
// Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
|
||||
// inheriting the currently loaded document's principal.
|
||||
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
||||
Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
|
||||
gBrowser.loadURIWithFlags(url, flags, null, null, postData);
|
||||
}
|
||||
|
||||
if (aTriggeringEvent instanceof MouseEvent) {
|
||||
// We have a mouse event (from the go button), so use the standard
|
||||
// UI link behaviors
|
||||
let where = whereToOpenLink(aTriggeringEvent, false, false);
|
||||
if (where != "current") {
|
||||
if (where == "current") {
|
||||
loadCurrent();
|
||||
} else {
|
||||
this.handleRevert();
|
||||
content.focus();
|
||||
}
|
||||
openUILinkIn(url, where,
|
||||
{ allowThirdPartyFixup: true, postData: postData });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -317,11 +327,7 @@
|
||||
aTriggeringEvent.preventDefault();
|
||||
aTriggeringEvent.stopPropagation();
|
||||
} else {
|
||||
// Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
|
||||
// inheriting the currently loaded document's principal.
|
||||
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
||||
Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
|
||||
gBrowser.loadURIWithFlags(url, flags, null, null, postData);
|
||||
loadCurrent();
|
||||
}
|
||||
|
||||
gBrowser.selectedBrowser.focus();
|
||||
|
@ -74,12 +74,4 @@ EXTRA_DSO_LDOPTS += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifndef MOZ_ENABLE_LIBXUL
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
# Doesn't work, couldn't figure out why
|
||||
#EXTRA_DSO_LIBS += thebes
|
||||
EXTRA_DSO_LDOPTS += $(LIBXUL_DIST)/lib/$(LIB_PREFIX)thebes.$(IMPORT_LIB_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -96,69 +96,55 @@ var PlacesUIUtils = {
|
||||
return bundle.GetStringFromName(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a transaction for copying a uri item from one container to another
|
||||
* as a bookmark.
|
||||
* @param aData
|
||||
* JSON object of dropped or pasted item properties
|
||||
* @param aContainer
|
||||
* The container being copied into
|
||||
* @param aIndex
|
||||
* The index within the container the item is copied to
|
||||
* @returns A nsITransaction object that performs the copy.
|
||||
*/
|
||||
_getURIItemCopyTransaction: function (aData, aContainer, aIndex) {
|
||||
return this.ptm.createItem(PlacesUtils._uri(aData.uri), aContainer, aIndex,
|
||||
aData.title, "");
|
||||
},
|
||||
get _copyableAnnotations() [
|
||||
this.DESCRIPTION_ANNO,
|
||||
this.LOAD_IN_SIDEBAR_ANNO,
|
||||
PlacesUtils.POST_DATA_ANNO,
|
||||
PlacesUtils.READ_ONLY_ANNO,
|
||||
],
|
||||
|
||||
/**
|
||||
* Get a transaction for copying a bookmark item from one container to
|
||||
* another.
|
||||
* Get a transaction for copying a uri item (either a bookmark or a history
|
||||
* entry) from one container to another.
|
||||
*
|
||||
* @param aData
|
||||
* JSON object of dropped or pasted item properties
|
||||
* @param aContainer
|
||||
* The container being copied into
|
||||
* @param aIndex
|
||||
* The index within the container the item is copied to
|
||||
* @param [optional] aExcludeAnnotations
|
||||
* Optional, array of annotations (listed by their names) to exclude
|
||||
* when copying the item.
|
||||
* @returns A nsITransaction object that performs the copy.
|
||||
* @return A nsITransaction object that performs the copy.
|
||||
*
|
||||
* @note Since a copy creates a completely new item, only some internal
|
||||
* annotations are synced from the old one.
|
||||
* @see this._copyableAnnotations for the list of copyable annotations.
|
||||
*/
|
||||
_getBookmarkItemCopyTransaction:
|
||||
function PUIU__getBookmarkItemCopyTransaction(aData, aContainer, aIndex,
|
||||
aExcludeAnnotations) {
|
||||
var itemURL = PlacesUtils._uri(aData.uri);
|
||||
var itemTitle = aData.title;
|
||||
var keyword = aData.keyword || null;
|
||||
var annos = aData.annos || [];
|
||||
// always exclude GUID when copying any item
|
||||
var excludeAnnos = [PlacesUtils.GUID_ANNO];
|
||||
if (aExcludeAnnotations)
|
||||
excludeAnnos = excludeAnnos.concat(aExcludeAnnotations);
|
||||
annos = annos.filter(function(aValue, aIndex, aArray) {
|
||||
return excludeAnnos.indexOf(aValue.name) == -1;
|
||||
});
|
||||
var childTxns = [];
|
||||
if (aData.dateAdded)
|
||||
childTxns.push(this.ptm.editItemDateAdded(null, aData.dateAdded));
|
||||
if (aData.lastModified)
|
||||
childTxns.push(this.ptm.editItemLastModified(null, aData.lastModified));
|
||||
if (aData.tags) {
|
||||
var tags = aData.tags.split(", ");
|
||||
// filter out tags already present, so that undo doesn't remove them
|
||||
// from pre-existing bookmarks
|
||||
var storedTags = PlacesUtils.tagging.getTagsForURI(itemURL);
|
||||
tags = tags.filter(function (aTag) {
|
||||
return (storedTags.indexOf(aTag) == -1);
|
||||
}, this);
|
||||
if (tags.length)
|
||||
childTxns.push(this.ptm.tagURI(itemURL, tags));
|
||||
_getURIItemCopyTransaction:
|
||||
function PUIU__getURIItemCopyTransaction(aData, aContainer, aIndex)
|
||||
{
|
||||
let transactions = [];
|
||||
if (aData.dateAdded) {
|
||||
transactions.push(
|
||||
new PlacesEditItemDateAddedTransaction(null, aData.dateAdded)
|
||||
);
|
||||
}
|
||||
if (aData.lastModified) {
|
||||
transactions.push(
|
||||
new PlacesEditItemLastModifiedTransaction(null, aData.lastModified)
|
||||
);
|
||||
}
|
||||
|
||||
return this.ptm.createItem(itemURL, aContainer, aIndex, itemTitle, keyword,
|
||||
annos, childTxns);
|
||||
let keyword = aData.keyword || null;
|
||||
let annos = [];
|
||||
if (aData.annos) {
|
||||
annos = aData.annos.filter(function (aAnno) {
|
||||
return this._copyableAnnotations.indexOf(aAnno.name) != -1;
|
||||
}, this);
|
||||
}
|
||||
|
||||
return new PlacesCreateBookmarkTransaction(PlacesUtils._uri(aData.uri),
|
||||
aContainer, aIndex, aData.title,
|
||||
keyword, annos, transactions);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -171,94 +157,133 @@ var PlacesUIUtils = {
|
||||
* The container we are copying into
|
||||
* @param aIndex
|
||||
* The index in the destination container to insert the new items
|
||||
* @returns A nsITransaction object that will perform the copy.
|
||||
* @return A nsITransaction object that will perform the copy.
|
||||
*
|
||||
* @note Since a copy creates a completely new item, only some internal
|
||||
* annotations are synced from the old one.
|
||||
* @see this._copyableAnnotations for the list of copyable annotations.
|
||||
*/
|
||||
_getFolderCopyTransaction:
|
||||
function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex) {
|
||||
function getChildItemsTransactions(aChildren) {
|
||||
var childItemsTransactions = [];
|
||||
var cc = aChildren.length;
|
||||
var index = aIndex;
|
||||
for (var i = 0; i < cc; ++i) {
|
||||
var txn = null;
|
||||
var node = aChildren[i];
|
||||
|
||||
function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex)
|
||||
{
|
||||
function getChildItemsTransactions(aChildren)
|
||||
{
|
||||
let transactions = [];
|
||||
let index = aIndex;
|
||||
aChildren.forEach(function (node, i) {
|
||||
// Make sure that items are given the correct index, this will be
|
||||
// passed by the transaction manager to the backend for the insertion.
|
||||
// Insertion behaves differently if index == DEFAULT_INDEX (append)
|
||||
if (aIndex != PlacesUtils.bookmarks.DEFAULT_INDEX)
|
||||
// Insertion behaves differently for DEFAULT_INDEX (append).
|
||||
if (aIndex != PlacesUtils.bookmarks.DEFAULT_INDEX) {
|
||||
index = i;
|
||||
}
|
||||
|
||||
if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) {
|
||||
if (node.livemark && node.annos) // node is a livemark
|
||||
txn = PlacesUIUtils._getLivemarkCopyTransaction(node, aContainer, index);
|
||||
else
|
||||
txn = PlacesUIUtils._getFolderCopyTransaction(node, aContainer, index);
|
||||
}
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR)
|
||||
txn = PlacesUIUtils.ptm.createSeparator(-1, index);
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE)
|
||||
txn = PlacesUIUtils._getBookmarkItemCopyTransaction(node, -1, index);
|
||||
|
||||
if (txn)
|
||||
childItemsTransactions.push(txn);
|
||||
else
|
||||
throw("Unexpected item under a bookmarks folder");
|
||||
}
|
||||
return childItemsTransactions;
|
||||
}
|
||||
|
||||
// tag folders use tag transactions
|
||||
if (aContainer == PlacesUtils.tagsFolderId) {
|
||||
var txns = [];
|
||||
if (aData.children) {
|
||||
aData.children.forEach(function(aChild) {
|
||||
txns.push(this.ptm.tagURI(PlacesUtils._uri(aChild.uri), [aData.title]));
|
||||
}, this);
|
||||
}
|
||||
return this.ptm.aggregateTransactions("addTags", txns);
|
||||
}
|
||||
else if (aData.livemark && aData.annos) {
|
||||
// Place is a Livemark Container
|
||||
return this._getLivemarkCopyTransaction(aData, aContainer, aIndex);
|
||||
if (node.livemark && node.annos) {
|
||||
transactions.push(
|
||||
PlacesUIUtils._getLivemarkCopyTransaction(node, aContainer, index)
|
||||
);
|
||||
}
|
||||
else {
|
||||
var childItems = getChildItemsTransactions(aData.children);
|
||||
if (aData.dateAdded)
|
||||
childItems.push(this.ptm.editItemDateAdded(null, aData.dateAdded));
|
||||
if (aData.lastModified)
|
||||
childItems.push(this.ptm.editItemLastModified(null, aData.lastModified));
|
||||
|
||||
var annos = aData.annos || [];
|
||||
annos = annos.filter(function(aAnno) {
|
||||
// always exclude GUID when copying any item
|
||||
return aAnno.name != PlacesUtils.GUID_ANNO;
|
||||
});
|
||||
return this.ptm.createFolder(aData.title, aContainer, aIndex, annos, childItems);
|
||||
transactions.push(
|
||||
PlacesUIUtils._getFolderCopyTransaction(node, aContainer, index)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR) {
|
||||
transactions.push(new PlacesCreateSeparatorTransaction(-1, index));
|
||||
}
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE) {
|
||||
transactions.push(
|
||||
PlacesUIUtils._getURIItemCopyTransaction(node, -1, index)
|
||||
);
|
||||
}
|
||||
else {
|
||||
throw new Error("Unexpected item under a bookmarks folder");
|
||||
}
|
||||
});
|
||||
return transactions;
|
||||
}
|
||||
|
||||
if (aContainer == PlacesUtils.tagsFolderId) { // Copying a tag folder.
|
||||
let transactions = [];
|
||||
if (aData.children) {
|
||||
aData.children.forEach(function(aChild) {
|
||||
transactions.push(
|
||||
new PlacesTagURITransaction(PlacesUtils._uri(aChild.uri),
|
||||
[aData.title])
|
||||
);
|
||||
});
|
||||
}
|
||||
return new PlacesAggregatedTransaction("addTags", transactions);
|
||||
}
|
||||
|
||||
if (aData.livemark && aData.annos) { // Copying a livemark.
|
||||
return this._getLivemarkCopyTransaction(aData, aContainer, aIndex);
|
||||
}
|
||||
|
||||
let transactions = getChildItemsTransactions(aData.children);
|
||||
if (aData.dateAdded) {
|
||||
transactions.push(
|
||||
new PlacesEditItemDateAddedTransaction(null, aData.dateAdded)
|
||||
);
|
||||
}
|
||||
if (aData.lastModified) {
|
||||
transactions.push(
|
||||
new PlacesEditItemLastModifiedTransaction(null, aData.lastModified)
|
||||
);
|
||||
}
|
||||
|
||||
let annos = [];
|
||||
if (aData.annos) {
|
||||
annos = aData.annos.filter(function (aAnno) {
|
||||
return this._copyableAnnotations.indexOf(aAnno.name) != -1;
|
||||
}, this);
|
||||
}
|
||||
|
||||
return new PlacesCreateFolderTransaction(aData.title, aContainer, aIndex,
|
||||
annos, transactions);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a transaction for copying a live bookmark item from one container to
|
||||
* another.
|
||||
*
|
||||
* @param aData
|
||||
* Unwrapped live bookmarkmark data
|
||||
* @param aContainer
|
||||
* The container we are copying into
|
||||
* @param aIndex
|
||||
* The index in the destination container to insert the new items
|
||||
* @return A nsITransaction object that will perform the copy.
|
||||
*
|
||||
* @note Since a copy creates a completely new item, only some internal
|
||||
* annotations are synced from the old one.
|
||||
* @see this._copyableAnnotations for the list of copyable annotations.
|
||||
*/
|
||||
_getLivemarkCopyTransaction:
|
||||
function PUIU__getLivemarkCopyTransaction(aData, aContainer, aIndex) {
|
||||
if (!aData.livemark || !aData.annos)
|
||||
throw("node is not a livemark");
|
||||
// Place is a Livemark Container
|
||||
var feedURI = null;
|
||||
var siteURI = null;
|
||||
aData.annos = aData.annos.filter(function(aAnno) {
|
||||
function PUIU__getLivemarkCopyTransaction(aData, aContainer, aIndex)
|
||||
{
|
||||
if (!aData.livemark || !aData.annos) {
|
||||
throw new Error("node is not a livemark");
|
||||
}
|
||||
|
||||
let feedURI, siteURI;
|
||||
let annos = [];
|
||||
if (aData.annos) {
|
||||
annos = aData.annos.filter(function (aAnno) {
|
||||
if (aAnno.name == PlacesUtils.LMANNO_FEEDURI) {
|
||||
feedURI = PlacesUtils._uri(aAnno.value);
|
||||
return false;
|
||||
}
|
||||
else if (aAnno.name == PlacesUtils.LMANNO_SITEURI) {
|
||||
siteURI = PlacesUtils._uri(aAnno.value);
|
||||
return false;
|
||||
}
|
||||
// always exclude GUID when copying any item
|
||||
return aAnno.name != PlacesUtils.GUID_ANNO;
|
||||
});
|
||||
return this.ptm.createLivemark(feedURI, siteURI, aData.title, aContainer,
|
||||
aIndex, aData.annos);
|
||||
return this._copyableAnnotations.indexOf(aAnno.name) != -1
|
||||
}, this);
|
||||
}
|
||||
|
||||
return new PlacesCreateLivemarkTransaction(feedURI, siteURI, aData.title,
|
||||
aContainer, aIndex, annos);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -277,39 +302,43 @@ var PlacesUIUtils = {
|
||||
* @returns An object implementing nsITransaction that can perform
|
||||
* the move/insert.
|
||||
*/
|
||||
makeTransaction: function PUIU_makeTransaction(data, type, container,
|
||||
index, copy) {
|
||||
makeTransaction:
|
||||
function PUIU_makeTransaction(data, type, container, index, copy)
|
||||
{
|
||||
switch (data.type) {
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||
if (copy)
|
||||
if (copy) {
|
||||
return this._getFolderCopyTransaction(data, container, index);
|
||||
}
|
||||
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
return new PlacesMoveItemTransaction(data.id, container, index);
|
||||
break;
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE:
|
||||
if (data.id == -1) // Not bookmarked.
|
||||
if (copy || data.id == -1) { // Id is -1 if the place is not bookmarked.
|
||||
return this._getURIItemCopyTransaction(data, container, index);
|
||||
}
|
||||
|
||||
if (copy)
|
||||
return this._getBookmarkItemCopyTransaction(data, container, index);
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
return new PlacesMoveItemTransaction(data.id, container, index);
|
||||
break;
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR:
|
||||
if (copy) {
|
||||
// There is no data in a separator, so copying it just amounts to
|
||||
// inserting a new separator.
|
||||
if (copy)
|
||||
return this.ptm.createSeparator(container, index);
|
||||
return new PlacesCreateSeparatorTransaction(container, index);
|
||||
}
|
||||
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
return new PlacesMoveItemTransaction(data.id, container, index);
|
||||
break;
|
||||
default:
|
||||
if (type == PlacesUtils.TYPE_X_MOZ_URL ||
|
||||
type == PlacesUtils.TYPE_UNICODE ||
|
||||
type == this.TYPE_TAB_DROP) {
|
||||
var title = (type != PlacesUtils.TYPE_UNICODE) ? data.title :
|
||||
data.uri;
|
||||
return this.ptm.createItem(PlacesUtils._uri(data.uri),
|
||||
let title = type != PlacesUtils.TYPE_UNICODE ? data.title
|
||||
: data.uri;
|
||||
return new PlacesCreateBookmarkTransaction(PlacesUtils._uri(data.uri),
|
||||
container, index, title);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,353 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function waitForBookmarkNotification(aNotification, aCallback, aProperty)
|
||||
{
|
||||
PlacesUtils.bookmarks.addObserver({
|
||||
validate: function (aMethodName, aData)
|
||||
{
|
||||
if (aMethodName == aNotification &&
|
||||
(!aProperty || aProperty == aData.property)) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
aCallback(aData);
|
||||
}
|
||||
},
|
||||
|
||||
// nsINavBookmarkObserver
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver]),
|
||||
onBeginUpdateBatch: function onBeginUpdateBatch()
|
||||
this.validate(arguments.callee.name, arguments),
|
||||
onEndUpdateBatch: function onEndUpdateBatch()
|
||||
this.validate(arguments.callee.name, arguments),
|
||||
onItemAdded: function onItemAdded(aItemId, aParentId, aIndex, aItemType,
|
||||
aURI, aTitle)
|
||||
{
|
||||
return this.validate(arguments.callee.name, { id: aItemId,
|
||||
index: aIndex,
|
||||
type: aItemType,
|
||||
url: aURI ? aURI.spec : null,
|
||||
title: aTitle });
|
||||
},
|
||||
onBeforeItemRemoved: function onBeforeItemRemoved()
|
||||
this.validate(arguments.callee.name, arguments),
|
||||
onItemRemoved: function onItemRemoved()
|
||||
this.validate(arguments.callee.name, arguments),
|
||||
onItemChanged: function onItemChanged(aItemId, aProperty, aIsAnno,
|
||||
aNewValue, aLastModified, aItemType)
|
||||
{
|
||||
return this.validate(arguments.callee.name,
|
||||
{ id: aItemId,
|
||||
get index() PlacesUtils.bookmarks.getItemIndex(this.id),
|
||||
type: aItemType,
|
||||
property: aProperty,
|
||||
get url() aItemType == PlacesUtils.bookmarks.TYPE_BOOKMARK ?
|
||||
PlacesUtils.bookmarks.getBookmarkURI(this.id).spec :
|
||||
null,
|
||||
get title() PlacesUtils.bookmarks.getItemTitle(this.id),
|
||||
});
|
||||
},
|
||||
onItemVisited: function onItemVisited()
|
||||
this.validate(arguments.callee.name, arguments),
|
||||
onItemMoved: function onItemMoved(aItemId, aOldParentId, aOldIndex,
|
||||
aNewParentId, aNewIndex, aItemType)
|
||||
{
|
||||
this.validate(arguments.callee.name, { id: aItemId,
|
||||
index: aNewIndex,
|
||||
type: aItemType });
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
function wrapNodeByIdAndParent(aItemId, aParentId)
|
||||
{
|
||||
let wrappedNode;
|
||||
let root = PlacesUtils.getFolderContents(aParentId, false, false).root;
|
||||
for (let i = 0; i < root.childCount; ++i) {
|
||||
let node = root.getChild(i);
|
||||
if (node.itemId == aItemId) {
|
||||
let type;
|
||||
if (PlacesUtils.nodeIsContainer(node)) {
|
||||
type = PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER;
|
||||
}
|
||||
else if (PlacesUtils.nodeIsURI(node)) {
|
||||
type = PlacesUtils.TYPE_X_MOZ_PLACE;
|
||||
}
|
||||
else if (PlacesUtils.nodeIsSeparator(node)) {
|
||||
type = PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR;
|
||||
}
|
||||
else {
|
||||
do_throw("Unknown node type");
|
||||
}
|
||||
wrappedNode = PlacesUtils.wrapNode(node, type);
|
||||
}
|
||||
}
|
||||
root.containerOpen = false;
|
||||
return JSON.parse(wrappedNode);
|
||||
}
|
||||
|
||||
add_test(function test_text_paste()
|
||||
{
|
||||
const TEST_URL = "http://places.moz.org/"
|
||||
const TEST_TITLE = "Places bookmark"
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.url, TEST_URL);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 0);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
{ title: TEST_TITLE, uri: TEST_URL },
|
||||
PlacesUtils.TYPE_X_MOZ_URL,
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
true // Unused for text.
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
});
|
||||
|
||||
add_test(function test_container()
|
||||
{
|
||||
const TEST_TITLE = "Places folder"
|
||||
|
||||
waitForBookmarkNotification("onItemChanged", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_FOLDER);
|
||||
do_check_eq(aData.index, 1);
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_FOLDER);
|
||||
do_check_eq(aData.index, 2);
|
||||
let id = aData.id;
|
||||
|
||||
waitForBookmarkNotification("onItemMoved", function(aData)
|
||||
{
|
||||
do_check_eq(aData.id, id);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_FOLDER);
|
||||
do_check_eq(aData.index, 1);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
1, // Move to position 1.
|
||||
false
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
});
|
||||
|
||||
try {
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
true
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
} catch(ex) {
|
||||
do_throw(ex);
|
||||
}
|
||||
}, "random-anno");
|
||||
|
||||
let id = PlacesUtils.bookmarks.createFolder(PlacesUtils.unfiledBookmarksFolderId,
|
||||
TEST_TITLE,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, PlacesUIUtils.DESCRIPTION_ANNO,
|
||||
"description", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, "random-anno",
|
||||
"random-value", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
});
|
||||
|
||||
|
||||
add_test(function test_separator()
|
||||
{
|
||||
waitForBookmarkNotification("onItemChanged", function(aData)
|
||||
{
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
|
||||
do_check_eq(aData.index, 3);
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
|
||||
do_check_eq(aData.index, 4);
|
||||
let id = aData.id;
|
||||
|
||||
waitForBookmarkNotification("onItemMoved", function(aData)
|
||||
{
|
||||
do_check_eq(aData.id, id);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_SEPARATOR);
|
||||
do_check_eq(aData.index, 1);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
1, // Move to position 1.
|
||||
false
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
});
|
||||
|
||||
try {
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
true
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
} catch(ex) {
|
||||
do_throw(ex);
|
||||
}
|
||||
}, "random-anno");
|
||||
|
||||
let id = PlacesUtils.bookmarks.insertSeparator(PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, "random-anno",
|
||||
"random-value", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
});
|
||||
|
||||
add_test(function test_bookmark()
|
||||
{
|
||||
const TEST_URL = "http://places.moz.org/"
|
||||
const TEST_TITLE = "Places bookmark"
|
||||
|
||||
waitForBookmarkNotification("onItemChanged", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.url, TEST_URL);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 5);
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.url, TEST_URL);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 6);
|
||||
let id = aData.id;
|
||||
|
||||
waitForBookmarkNotification("onItemMoved", function(aData)
|
||||
{
|
||||
do_check_eq(aData.id, id);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 1);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
1, // Move to position 1.
|
||||
false
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
});
|
||||
|
||||
try {
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId),
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
true
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
} catch(ex) {
|
||||
do_throw(ex);
|
||||
}
|
||||
}, "random-anno");
|
||||
|
||||
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
||||
NetUtil.newURI(TEST_URL),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
TEST_TITLE);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, PlacesUIUtils.DESCRIPTION_ANNO,
|
||||
"description", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
PlacesUtils.annotations.setItemAnnotation(id, "random-anno",
|
||||
"random-value", 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
});
|
||||
|
||||
add_test(function test_visit()
|
||||
{
|
||||
const TEST_URL = "http://places.moz.org/"
|
||||
const TEST_TITLE = "Places bookmark"
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.url, TEST_URL);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 7);
|
||||
|
||||
waitForBookmarkNotification("onItemAdded", function(aData)
|
||||
{
|
||||
do_check_eq(aData.title, TEST_TITLE);
|
||||
do_check_eq(aData.url, TEST_URL);
|
||||
do_check_eq(aData.type, PlacesUtils.bookmarks.TYPE_BOOKMARK);
|
||||
do_check_eq(aData.index, 8);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
try {
|
||||
let node = wrapNodeByIdAndParent(aData.id, PlacesUtils.unfiledBookmarksFolderId);
|
||||
// Simulate a not-bookmarked node, will copy it to a new bookmark.
|
||||
node.id = -1;
|
||||
let txn = PlacesUIUtils.makeTransaction(
|
||||
node,
|
||||
0, // Unused for real nodes.
|
||||
PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
true
|
||||
);
|
||||
PlacesUtils.transactionManager.doTransaction(txn);
|
||||
} catch(ex) {
|
||||
do_throw(ex);
|
||||
}
|
||||
});
|
||||
|
||||
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
||||
NetUtil.newURI(TEST_URL),
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
TEST_TITLE);
|
||||
});
|
||||
|
||||
add_test(function check_annotations() {
|
||||
// As last step check how many items for each annotation exist.
|
||||
|
||||
// Copies should retain the description annotation.
|
||||
let descriptions =
|
||||
PlacesUtils.annotations.getItemsWithAnnotation(PlacesUIUtils.DESCRIPTION_ANNO, {});
|
||||
do_check_eq(descriptions.length, 4);
|
||||
|
||||
// Only the original bookmarks should have this annotation.
|
||||
let others = PlacesUtils.annotations.getItemsWithAnnotation("random-anno", {});
|
||||
do_check_eq(others.length, 3);
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
function run_test()
|
||||
{
|
||||
run_next_test();
|
||||
}
|
@ -41,9 +41,7 @@ MOZ_APP_VENDOR=Mozilla
|
||||
MOZ_UPDATER=1
|
||||
MOZ_PHOENIX=1
|
||||
|
||||
MOZ_ENABLE_LIBXUL=1
|
||||
MOZ_CHROME_FILE_FORMAT=omni
|
||||
MOZ_STATIC_BUILD_UNSUPPORTED=1
|
||||
# always enabled for form history
|
||||
MOZ_MORKREADER=1
|
||||
MOZ_SAFE_BROWSING=1
|
||||
|
@ -47,16 +47,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
MOZ_PKG_REMOVALS = $(srcdir)/removed-files.in
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
MOZ_PKG_MANIFEST_P = $(srcdir)/package-manifest.in
|
||||
else
|
||||
define message
|
||||
You need to build with --enable-libxul (the default, unless you specify
|
||||
--disable-libxul or --enable-shared or --enable-debug) to package a build.
|
||||
endef
|
||||
default libs installer::
|
||||
$(error $(message))
|
||||
endif
|
||||
|
||||
MOZ_NONLOCALIZED_PKG_LIST = \
|
||||
xpcom \
|
||||
@ -127,8 +118,7 @@ GENERATE_CACHE = \
|
||||
rm -rf jsloader && \
|
||||
$(UNZIP) startupCache.zip && \
|
||||
rm startupCache.zip && \
|
||||
find jsloader | xargs touch -t 201001010000 && \
|
||||
$(ZIP) -r9mX omni.jar jsloader
|
||||
$(ZIP) -r9m omni.jar jsloader
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/toolkit/mozapps/installer/packager.mk
|
||||
|
@ -1277,21 +1277,13 @@ xpicleanup@BIN_SUFFIX@
|
||||
mozcrt19.dll
|
||||
#endif
|
||||
#endif
|
||||
#ifdef MOZ_ENABLE_LIBXUL
|
||||
@DLL_PREFIX@xpcom_core@DLL_SUFFIX@
|
||||
components/@DLL_PREFIX@jar50@DLL_SUFFIX@
|
||||
#ifdef XP_WIN
|
||||
@DLL_PREFIX@xpcom_core@DLL_SUFFIX@
|
||||
components/@DLL_PREFIX@jar50@DLL_SUFFIX@
|
||||
#ifdef XP_WIN
|
||||
components/xpinstal.dll
|
||||
#else
|
||||
#else
|
||||
components/@DLL_PREFIX@jsd@DLL_SUFFIX@
|
||||
components/@DLL_PREFIX@xpinstall@DLL_SUFFIX@
|
||||
#endif
|
||||
#else
|
||||
#ifdef XP_MACOSX
|
||||
XUL
|
||||
#else
|
||||
@DLL_PREFIX@xul@DLL_SUFFIX@
|
||||
#endif
|
||||
#endif
|
||||
#ifndef MOZ_UPDATER
|
||||
components/nsUpdateService.js
|
||||
|
@ -82,10 +82,6 @@
|
||||
<!ENTITY environmentMenu.label "Environment">
|
||||
<!ENTITY environmentMenu.accesskey "N">
|
||||
|
||||
<!-- LOCALIZATION NOTE (contextMenu.label, accesskey): No longer used.
|
||||
<!ENTITY contextMenu.label "Context">
|
||||
<!ENTITY contextMenu.accesskey "C">
|
||||
-->
|
||||
|
||||
<!ENTITY contentContext.label "Content">
|
||||
<!ENTITY contentContext.accesskey "C">
|
||||
@ -99,11 +95,6 @@
|
||||
<!ENTITY browserContext.label "Browser">
|
||||
<!ENTITY browserContext.accesskey "B">
|
||||
|
||||
<!-- LOCALIZATION NOTE (chromeContext.label, accesskey): No longer used.
|
||||
<!ENTITY chromeContext.label "Chrome">
|
||||
<!ENTITY chromeContext.accesskey "H">
|
||||
-->
|
||||
|
||||
<!-- LOCALIZATION NOTE (resetContext.label): This command allows the developer
|
||||
- to reset/clear the global object of the environment where the code executes.
|
||||
-->
|
||||
|
@ -52,7 +52,7 @@ interface nsIContentSecurityPolicy;
|
||||
[ptr] native JSContext(JSContext);
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
|
||||
[scriptable, uuid(799ab95c-0038-4e0f-b705-74c21f185bb5)]
|
||||
[scriptable, uuid(B406A2DB-E547-4C95-B8E2-AD09ECB54CE0)]
|
||||
interface nsIPrincipal : nsISerializable
|
||||
{
|
||||
/**
|
||||
@ -86,6 +86,11 @@ interface nsIPrincipal : nsISerializable
|
||||
*/
|
||||
boolean equals(in nsIPrincipal other);
|
||||
|
||||
/**
|
||||
* Like equals, but doesn't take document.domain changes into account.
|
||||
*/
|
||||
boolean equalsIgnoringDomain(in nsIPrincipal other);
|
||||
|
||||
/**
|
||||
* Returns a hash value for the principal.
|
||||
*/
|
||||
|
@ -131,6 +131,9 @@ protected:
|
||||
const nsACString& aPrettyName,
|
||||
nsISupports* aCert);
|
||||
|
||||
// Checks whether this principal's certificate equals aOther's.
|
||||
PRBool CertificateEquals(nsIPrincipal *aOther);
|
||||
|
||||
// Keep this is a pointer, even though it may slightly increase the
|
||||
// cost of keeping a certificate, this is a good tradeoff though since
|
||||
// it is very rare that we actually have a certificate.
|
||||
|
@ -162,6 +162,12 @@ nsNullPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::EqualsIgnoringDomain(nsIPrincipal *aOther, PRBool *aResult)
|
||||
{
|
||||
return Equals(aOther, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNullPrincipal::GetHashValue(PRUint32 *aResult)
|
||||
{
|
||||
|
@ -309,42 +309,52 @@ nsPrincipal::SetSecurityPolicy(void* aSecurityPolicy)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
|
||||
PRBool
|
||||
nsPrincipal::CertificateEquals(nsIPrincipal *aOther)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
|
||||
if (!aOther) {
|
||||
NS_WARNING("Need a principal to compare this to!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (this != aOther) {
|
||||
PRBool otherHasCert;
|
||||
aOther->GetHasCertificate(&otherHasCert);
|
||||
if (otherHasCert != (mCert != nsnull)) {
|
||||
// One has a cert while the other doesn't. Not equal.
|
||||
return NS_OK;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (mCert) {
|
||||
if (!mCert)
|
||||
return PR_TRUE;
|
||||
|
||||
nsCAutoString str;
|
||||
aOther->GetFingerprint(str);
|
||||
*aResult = str.Equals(mCert->fingerprint);
|
||||
if (!str.Equals(mCert->fingerprint))
|
||||
return PR_FALSE;
|
||||
|
||||
// If either subject name is empty, just let the result stand (so that
|
||||
// nsScriptSecurityManager::SetCanEnableCapability works), but if they're
|
||||
// both non-empty, only claim equality if they're equal.
|
||||
if (*aResult && !mCert->subjectName.IsEmpty()) {
|
||||
if (!mCert->subjectName.IsEmpty()) {
|
||||
// Check the other principal's subject name
|
||||
aOther->GetSubjectName(str);
|
||||
*aResult = str.Equals(mCert->subjectName) || str.IsEmpty();
|
||||
return str.Equals(mCert->subjectName) || str.IsEmpty();
|
||||
}
|
||||
|
||||
if (!*aResult) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
|
||||
{
|
||||
if (!aOther) {
|
||||
NS_WARNING("Need a principal to compare this to!");
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (this != aOther) {
|
||||
if (!CertificateEquals(aOther)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mCert) {
|
||||
// If either principal has no URI, it's the saved principal from
|
||||
// preferences; in that case, test true. Do NOT test true if the two
|
||||
// principals have URIs with different codebases.
|
||||
@ -356,6 +366,7 @@ nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
|
||||
}
|
||||
|
||||
if (!otherURI || !mCodebase) {
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -373,6 +384,34 @@ nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::EqualsIgnoringDomain(nsIPrincipal *aOther, PRBool *aResult)
|
||||
{
|
||||
if (this == aOther) {
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aResult = PR_FALSE;
|
||||
if (!CertificateEquals(aOther)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> otherURI;
|
||||
nsresult rv = aOther->GetURI(getter_AddRefs(otherURI));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mCodebase,
|
||||
"shouldn't be calling this on principals from preferences");
|
||||
|
||||
// Compare codebases.
|
||||
*aResult = nsScriptSecurityManager::SecurityCompareURIs(mCodebase,
|
||||
otherURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::Subsumes(nsIPrincipal *aOther, PRBool *aResult)
|
||||
{
|
||||
|
@ -3405,7 +3405,7 @@ nsresult nsScriptSecurityManager::Init()
|
||||
|
||||
::JS_BeginRequest(cx);
|
||||
if (sEnabledID == JSID_VOID)
|
||||
sEnabledID = INTERNED_STRING_TO_JSID(::JS_InternString(cx, "enabled"));
|
||||
sEnabledID = INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "enabled"));
|
||||
::JS_EndRequest(cx);
|
||||
|
||||
InitPrefs();
|
||||
|
@ -110,6 +110,12 @@ nsSystemPrincipal::Equals(nsIPrincipal *other, PRBool *result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::EqualsIgnoringDomain(nsIPrincipal *other, PRBool *result)
|
||||
{
|
||||
return Equals(other, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::Subsumes(nsIPrincipal *other, PRBool *result)
|
||||
{
|
||||
|
@ -122,10 +122,8 @@ ifdef WRAP_SYSTEM_INCLUDES
|
||||
export::
|
||||
if test ! -d system_wrappers; then mkdir system_wrappers; fi
|
||||
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
|
||||
-DBUILD_STATIC_LIBS=$(BUILD_STATIC_LIBS) \
|
||||
-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
|
||||
-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
|
||||
-DMOZ_ENABLE_LIBXUL=$(MOZ_ENABLE_LIBXUL) \
|
||||
-DMOZ_NATIVE_HUNSPELL=$(MOZ_NATIVE_HUNSPELL) \
|
||||
-DMOZ_NATIVE_BZ2=$(MOZ_NATIVE_BZ2) \
|
||||
-DMOZ_NATIVE_ZLIB=$(MOZ_NATIVE_ZLIB) \
|
||||
|
@ -124,8 +124,6 @@ STDCXX_COMPAT = @STDCXX_COMPAT@
|
||||
INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
|
||||
MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
|
||||
MOZ_MAIL_NEWS = @MOZ_MAIL_NEWS@
|
||||
BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
|
||||
MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
|
||||
ENABLE_TESTS = @ENABLE_TESTS@
|
||||
IBMBIDI = @IBMBIDI@
|
||||
MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@
|
||||
@ -455,11 +453,7 @@ ZLIB_LIBS = @ZLIB_LIBS@
|
||||
ZLIB_REQUIRES =
|
||||
else
|
||||
ZLIB_CFLAGS = @MOZ_ZLIB_CFLAGS@
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
MOZ_ZLIB_LIBS = @MOZ_ZLIB_LIBS@
|
||||
else
|
||||
ZLIB_LIBS = @MOZ_ZLIB_LIBS@
|
||||
endif
|
||||
ZLIB_REQUIRES = zlib
|
||||
endif
|
||||
|
||||
|
@ -245,35 +245,12 @@ endif # WINNT && !GNU_CC
|
||||
|
||||
#
|
||||
# Build using PIC by default
|
||||
# Do not use PIC if not building a shared lib (see exceptions below)
|
||||
#
|
||||
|
||||
ifndef BUILD_STATIC_LIBS
|
||||
_ENABLE_PIC=1
|
||||
endif
|
||||
ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
|
||||
_ENABLE_PIC=1
|
||||
endif
|
||||
|
||||
# If module is going to be merged into the nsStaticModule,
|
||||
# make sure that the entry points are translated and
|
||||
# the module is built static.
|
||||
|
||||
ifdef IS_COMPONENT
|
||||
ifdef EXPORT_LIBRARY
|
||||
ifneq (,$(BUILD_STATIC_LIBS))
|
||||
ifdef MODULE_NAME
|
||||
DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
|
||||
FORCE_STATIC_LIB=1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Determine if module being compiled is destined
|
||||
# to be merged into libxul
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
ifdef LIBXUL_LIBRARY
|
||||
ifdef IS_COMPONENT
|
||||
ifdef MODULE_NAME
|
||||
@ -283,17 +260,14 @@ $(error Component makefile does not specify MODULE_NAME.)
|
||||
endif
|
||||
endif
|
||||
FORCE_STATIC_LIB=1
|
||||
_ENABLE_PIC=1
|
||||
SHORT_LIBNAME=
|
||||
endif
|
||||
endif
|
||||
|
||||
# If we are building this component into an extension/xulapp, it cannot be
|
||||
# statically linked. In the future we may want to add a xulapp meta-component
|
||||
# build option.
|
||||
|
||||
ifdef XPI_NAME
|
||||
_ENABLE_PIC=1
|
||||
ifdef IS_COMPONENT
|
||||
EXPORT_LIBRARY=
|
||||
FORCE_STATIC_LIB=
|
||||
@ -301,19 +275,6 @@ FORCE_SHARED_LIB=1
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Disable PIC if necessary
|
||||
#
|
||||
|
||||
ifndef _ENABLE_PIC
|
||||
DSO_CFLAGS=
|
||||
ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
|
||||
DSO_PIC_CFLAGS=-mdynamic-no-pic
|
||||
else
|
||||
DSO_PIC_CFLAGS=
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef SHARED_LIBRARY_NAME
|
||||
ifdef LIBRARY_NAME
|
||||
SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
|
||||
@ -371,7 +332,6 @@ endif
|
||||
|
||||
# Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
|
||||
# building libxul libraries
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
ifdef LIBXUL_LIBRARY
|
||||
DEFINES += \
|
||||
-D_IMPL_NS_COM \
|
||||
@ -388,20 +348,6 @@ ifndef JS_SHARED_LIBRARY
|
||||
DEFINES += -DSTATIC_EXPORTABLE_JS_API
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Force _all_ exported methods to be |_declspec(dllexport)| when we're
|
||||
# building them into the executable.
|
||||
|
||||
ifeq (,$(filter-out WINNT OS2, $(OS_ARCH)))
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
DEFINES += \
|
||||
-D_IMPL_NS_GFX \
|
||||
-D_IMPL_NS_MSG_BASE \
|
||||
-D_IMPL_NS_WIDGET \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Flags passed to JarMaker.py
|
||||
MAKE_JARS_FLAGS = \
|
||||
|
@ -201,10 +201,15 @@ def optimizejar(jar, outjar, inlog = None):
|
||||
readahead = struct.unpack("<I", jarblob.readAt(0, 4))[0]
|
||||
print("%s: startup data ends at byte %d" % (outjar, readahead));
|
||||
|
||||
total_stripped = 0;
|
||||
jarblob.offset = cdir_offset
|
||||
central_directory = []
|
||||
for i in range(0, dirend.cdir_entries):
|
||||
entry = jarblob.read_struct(cdir_entry)
|
||||
if entry.filename[-1:] == "/":
|
||||
total_stripped += len(entry.pack())
|
||||
else:
|
||||
total_stripped += entry.extrafield_size
|
||||
central_directory.append(entry)
|
||||
|
||||
reordered_count = 0
|
||||
@ -235,7 +240,7 @@ def optimizejar(jar, outjar, inlog = None):
|
||||
# This also lets us specify how many entries should be preread
|
||||
dirend.cdir_offset = 4
|
||||
# make room for central dir + end of dir + 4 extra bytes at front
|
||||
out_offset = dirend.cdir_offset + dirend.cdir_size + size_of(cdir_end)
|
||||
out_offset = dirend.cdir_offset + dirend.cdir_size + size_of(cdir_end) - total_stripped
|
||||
outfd.seek(out_offset)
|
||||
|
||||
cdir_data = ""
|
||||
@ -245,6 +250,19 @@ def optimizejar(jar, outjar, inlog = None):
|
||||
# read in the header twice..first for comparison, second time for convenience when writing out
|
||||
jarfile = jarblob.read_struct(local_file_header, entry.offset)
|
||||
assert_true(jarfile.filename == entry.filename, "Directory/Localheader mismatch")
|
||||
# drop directory entries
|
||||
if entry.filename[-1:] == "/":
|
||||
total_stripped += len(jarfile.pack())
|
||||
dirend.cdir_entries -= 1
|
||||
continue
|
||||
# drop extra field data
|
||||
else:
|
||||
total_stripped += jarfile.extra_field_size;
|
||||
entry.extrafield = jarfile.extra_field = ""
|
||||
entry.extrafield_size = jarfile.extra_field_size = 0
|
||||
# January 1st, 2010
|
||||
entry.lastmod_date = jarfile.lastmod_date = ((2010 - 1980) << 9) | (1 << 5) | 1
|
||||
entry.lastmod_time = jarfile.lastmod_time = 0
|
||||
data = jarfile.pack()
|
||||
outfd.write(data)
|
||||
old_entry_offset = entry.offset
|
||||
@ -270,11 +288,11 @@ def optimizejar(jar, outjar, inlog = None):
|
||||
if inlog is None:
|
||||
dirend.cdir_offset = out_offset
|
||||
|
||||
dirend.cdir_size = len(cdir_data)
|
||||
dirend_data = dirend.pack()
|
||||
assert_true(size_of(cdir_end) == len(dirend_data), "Failed to serialize directory end correctly. Serialized size;%d, expected:%d"%(len(dirend_data), size_of(cdir_end)));
|
||||
|
||||
outfd.seek(dirend.cdir_offset)
|
||||
assert_true(len(cdir_data) == dirend.cdir_size, "Failed to serialize central directory correctly. Serialized size;%d, expected:%d expected-size:%d" % (len(cdir_data), dirend.cdir_size, dirend.cdir_size - len(cdir_data)));
|
||||
outfd.write(cdir_data)
|
||||
outfd.write(dirend_data)
|
||||
|
||||
@ -286,6 +304,7 @@ def optimizejar(jar, outjar, inlog = None):
|
||||
outfd.seek(out_offset)
|
||||
outfd.write(dirend_data)
|
||||
|
||||
print "Stripped %d bytes" % total_stripped
|
||||
print "%s %d/%d in %s" % (("Ordered" if inlog is not None else "Deoptimized"),
|
||||
reordered_count, len(central_directory), outjar)
|
||||
outfd.close()
|
||||
@ -296,20 +315,15 @@ if len(sys.argv) != 5:
|
||||
exit(1)
|
||||
|
||||
def optimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR):
|
||||
if not os.path.exists(JAR_LOG_DIR):
|
||||
print("No jar logs found in %s. No jars to optimize." % JAR_LOG_DIR)
|
||||
exit(0)
|
||||
|
||||
ls = os.listdir(JAR_LOG_DIR)
|
||||
for logfile in ls:
|
||||
if not logfile.endswith(".jar.log"):
|
||||
ls = os.listdir(IN_JAR_DIR)
|
||||
for jarfile in ls:
|
||||
if not jarfile.endswith(".jar"):
|
||||
continue
|
||||
injarfile = os.path.join(IN_JAR_DIR, logfile[:-4])
|
||||
outjarfile = os.path.join(OUT_JAR_DIR, logfile[:-4])
|
||||
if not os.path.exists(injarfile):
|
||||
print "Warning: Skipping %s, %s doesn't exist" % (logfile, injarfile)
|
||||
continue
|
||||
logfile = os.path.join(JAR_LOG_DIR, logfile)
|
||||
injarfile = os.path.join(IN_JAR_DIR, jarfile)
|
||||
outjarfile = os.path.join(OUT_JAR_DIR, jarfile)
|
||||
logfile = os.path.join(JAR_LOG_DIR, jarfile + ".log")
|
||||
if not os.path.isfile(logfile):
|
||||
logfile = None
|
||||
optimizejar(injarfile, outjarfile, logfile)
|
||||
|
||||
def deoptimize(JAR_LOG_DIR, IN_JAR_DIR, OUT_JAR_DIR):
|
||||
|
@ -216,7 +216,7 @@ endif # ENABLE_TESTS
|
||||
#
|
||||
# Library rules
|
||||
#
|
||||
# If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
|
||||
# If FORCE_STATIC_LIB is set, build a static library.
|
||||
# Otherwise, build a shared library.
|
||||
#
|
||||
|
||||
@ -239,7 +239,7 @@ endif
|
||||
endif
|
||||
|
||||
ifdef LIBRARY
|
||||
ifneq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
|
||||
ifdef FORCE_SHARED_LIB
|
||||
ifdef MKSHLIB
|
||||
|
||||
ifdef LIB_IS_C_ONLY
|
||||
@ -266,24 +266,12 @@ ifeq ($(OS_ARCH),OS2)
|
||||
DEF_FILE := $(SHARED_LIBRARY:.dll=.def)
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
EMBED_MANIFEST_AT=2
|
||||
endif
|
||||
|
||||
endif # MKSHLIB
|
||||
endif # FORCE_SHARED_LIB && !BUILD_STATIC_LIBS
|
||||
endif # FORCE_SHARED_LIB
|
||||
endif # LIBRARY
|
||||
|
||||
ifeq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
|
||||
LIBRARY := $(NULL)
|
||||
endif
|
||||
|
||||
ifeq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
|
||||
SHARED_LIBRARY := $(NULL)
|
||||
DEF_FILE := $(NULL)
|
||||
IMPORT_LIBRARY := $(NULL)
|
||||
endif
|
||||
|
||||
ifdef FORCE_STATIC_LIB
|
||||
ifndef FORCE_SHARED_LIB
|
||||
SHARED_LIBRARY := $(NULL)
|
||||
@ -785,12 +773,6 @@ export::
|
||||
ifdef LIBRARY_NAME
|
||||
ifdef EXPORT_LIBRARY
|
||||
ifdef IS_COMPONENT
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMPS) $(STATIC_LIBRARY_NAME)
|
||||
ifdef MODULE_NAME
|
||||
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
|
||||
endif
|
||||
endif # BUILD_STATIC_LIBS
|
||||
else # !IS_COMPONENT
|
||||
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_LIBS) $(STATIC_LIBRARY_NAME)
|
||||
endif # IS_COMPONENT
|
||||
|
@ -1,119 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Static components makefile
|
||||
# Include this makefile after config/config.mk & before config/rules.mk
|
||||
# This makefile will provide the defines for statically linking
|
||||
# all of the components into the binary.
|
||||
|
||||
STATIC_CPPSRCS += nsStaticComponents.cpp
|
||||
STATIC_DEFINES += -D_BUILD_STATIC_BIN=1
|
||||
STATIC_REQUIRES += \
|
||||
xpcom \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
STATIC_EXTRA_LIBS += \
|
||||
$(addsuffix .$(LIB_SUFFIX),$(addprefix $(DEPTH)/staticlib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) \
|
||||
$(addsuffix .$(LIB_SUFFIX),$(addprefix $(DEPTH)/staticlib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS)))) \
|
||||
$(NULL)
|
||||
|
||||
STATIC_COMPONENT_LIST = $(shell cat $(FINAL_LINK_COMP_NAMES))
|
||||
|
||||
STATIC_EXTRA_DEPS += $(FINAL_LINK_COMPS) $(FINAL_LINK_LIBS) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DEPTH)/staticlib/components/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_COMPS)))) $(addsuffix .$(LIB_SUFFIX),$(addprefix $(DEPTH)/staticlib/$(LIB_PREFIX),$(shell cat $(FINAL_LINK_LIBS))))
|
||||
|
||||
STATIC_EXTRA_DEPS += \
|
||||
$(topsrcdir)/config/static-config.mk \
|
||||
$(topsrcdir)/config/static-rules.mk \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PSM
|
||||
STATIC_EXTRA_DEPS += $(NSS_DEP_LIBS)
|
||||
endif
|
||||
|
||||
STATIC_EXTRA_LIBS += \
|
||||
$(PNG_LIBS) \
|
||||
$(JPEG_LIBS) \
|
||||
$(ZLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PSM
|
||||
STATIC_EXTRA_LIBS += \
|
||||
$(NSS_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
STATIC_EXTRA_LIBS += $(MOZ_CAIRO_LIBS)
|
||||
|
||||
STATIC_EXTRA_LIBS += $(QCMS_LIBS)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
STATIC_EXTRA_LIBS += $(XLDFLAGS) $(XT_LIBS) -lgthread-2.0
|
||||
STATIC_EXTRA_LIBS += $(MOZ_PANGO_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_STORAGE
|
||||
STATIC_EXTRA_LIBS += $(SQLITE_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
|
||||
STATIC_EXTRA_LIBS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_SYDNEYAUDIO
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
STATIC_EXTRA_LIBS += $(MOZ_ALSA_LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Component Makefile always brings in this.
|
||||
# STATIC_EXTRA_LIBS += $(TK_LIBS)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool imm32)
|
||||
# XXX temporary workaround until link ordering issue is solved
|
||||
ifdef GNU_CC
|
||||
STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,winmm wsock32 gdi32)
|
||||
endif
|
||||
STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME, usp10)
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
STATIC_EXTRA_LIBS += $(call EXPAND_LIBNAME,odm cfg)
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/config
|
@ -1,25 +0,0 @@
|
||||
|
||||
ifdef _NO_AUTO_VARS
|
||||
_TARGET = $(srcdir)/$(@F)
|
||||
else
|
||||
_TARGET = $@
|
||||
endif
|
||||
|
||||
$(warning FINAL_LINK_COMP_NAMES = $(FINAL_LINK_COMP_NAMES))
|
||||
$(warning FINAL_LINK_COMPS = $(FINAL_LINK_COMPS))
|
||||
|
||||
nsStaticComponents.cpp: $(topsrcdir)/config/nsStaticComponents.cpp.in $(GLOBAL_DEPS) $(FINAL_LINK_COMP_NAMES)
|
||||
rm -f $@
|
||||
cat $< | \
|
||||
sed -e "s|%MODULE_LIST%|$(foreach m, $(STATIC_COMPONENT_LIST),MODULE($(m)))|" \
|
||||
> $(_TARGET)
|
||||
|
||||
GARBAGE += nsStaticComponents.cpp
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
LDFLAGS += -Wl,-LD_LAYOUT:lgot_buffer=80
|
||||
endif
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
LIBS += -framework QuickTime -framework IOKit -lcrypto
|
||||
endif
|
@ -70,9 +70,6 @@ bstring.h
|
||||
builtin.h
|
||||
Button.h
|
||||
byteswap.h
|
||||
#if MOZ_ENABLE_LIBXUL!=1
|
||||
#define WRAP_CAIRO_HEADERS
|
||||
#endif
|
||||
#if MOZ_TREE_CAIRO!=1
|
||||
#define WRAP_CAIRO_HEADERS
|
||||
#endif
|
||||
@ -994,15 +991,6 @@ png.h
|
||||
#if MOZ_NATIVE_ZLIB==1
|
||||
zlib.h
|
||||
#endif
|
||||
#if MOZ_ENABLE_LIBXUL!=1
|
||||
#if BUILD_STATIC_LIBS!=1
|
||||
#define WRAP_LCMS_HEADERS
|
||||
#endif
|
||||
#endif
|
||||
#ifdef WRAP_LCMS_HEADERS
|
||||
icc34.h
|
||||
lcms.h
|
||||
#endif
|
||||
#ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
|
||||
libsn/sn.h
|
||||
libsn/sn-common.h
|
||||
|
35
configure.in
35
configure.in
@ -4433,8 +4433,6 @@ dnl =
|
||||
dnl ========================================================
|
||||
MOZ_ARG_HEADER(External Packages)
|
||||
|
||||
MOZ_ENABLE_LIBXUL=1
|
||||
|
||||
MOZ_ARG_WITH_STRING(libxul-sdk,
|
||||
[ --with-libxul-sdk=PFX Use the libXUL SDK at <PFX>],
|
||||
LIBXUL_SDK_DIR=$withval)
|
||||
@ -4448,7 +4446,6 @@ elif test -n "$LIBXUL_SDK_DIR" -a "$LIBXUL_SDK_DIR" != "no"; then
|
||||
AC_MSG_ERROR([$LIBXUL_SDK/include/xpcom-config.h doesn't exist])
|
||||
fi
|
||||
|
||||
MOZ_ENABLE_LIBXUL=1
|
||||
fi
|
||||
AC_SUBST(LIBXUL_SDK)
|
||||
|
||||
@ -4465,10 +4462,6 @@ MOZ_ARG_WITH_BOOL(system-libxul,
|
||||
[ --with-system-libxul Use system installed libxul SDK],
|
||||
SYSTEM_LIBXUL=1)
|
||||
|
||||
if test -n "$SYSTEM_LIBXUL" -a -z "$MOZ_ENABLE_LIBXUL"; then
|
||||
AC_MSG_ERROR([--with-system-libxul needs --with-libxul-sdk])
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = If NSPR was not detected in the system,
|
||||
dnl = use the one in the source tree (mozilla/nsprpub)
|
||||
@ -4796,7 +4789,6 @@ dnl ========================================================
|
||||
|
||||
MOZ_ARG_HEADER(Application)
|
||||
|
||||
BUILD_STATIC_LIBS=
|
||||
ENABLE_TESTS=1
|
||||
MOZ_ACTIVEX_SCRIPTING_SUPPORT=
|
||||
MOZ_BRANDING_DIRECTORY=
|
||||
@ -8101,22 +8093,6 @@ dnl =
|
||||
dnl ========================================================
|
||||
MOZ_ARG_HEADER(Static build options)
|
||||
|
||||
MOZ_ARG_ENABLE_BOOL(static,
|
||||
[ --enable-static Enable building internal static libs],
|
||||
BUILD_STATIC_LIBS=1,
|
||||
BUILD_STATIC_LIBS=)
|
||||
|
||||
MOZ_ENABLE_LIBXUL=1
|
||||
|
||||
MOZ_ARG_DISABLE_BOOL(libxul,
|
||||
[ --disable-libxul Disable building libxul (not supported)],
|
||||
MOZ_ENABLE_LIBXUL=,
|
||||
MOZ_ENABLE_LIBXUL=1)
|
||||
|
||||
if test -z "$MOZ_ENABLE_LIBXUL"; then
|
||||
AC_MSG_ERROR([--disable-libxul is no longer supported.])
|
||||
fi
|
||||
|
||||
# split JS out by default to avoid VS2005 PGO crash (bug 591836).
|
||||
if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" != "x86_64" ; then
|
||||
ENABLE_SHARED_JS=1
|
||||
@ -8137,17 +8113,8 @@ else
|
||||
fi
|
||||
AC_SUBST(JS_SHARED_LIBRARY)
|
||||
|
||||
if test -n "$MOZ_STATIC_BUILD_UNSUPPORTED" -a -n "$BUILD_STATIC_LIBS"; then
|
||||
AC_MSG_ERROR([--enable-static is not supported for building $MOZ_BUILD_APP.])
|
||||
fi
|
||||
|
||||
if test -n "$MOZ_ENABLE_LIBXUL" -a -n "$BUILD_STATIC_LIBS"; then
|
||||
AC_MSG_ERROR([--enable-libxul is not compatible with --enable-static])
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBXUL_LIBS)
|
||||
XPCOM_LIBS="$LIBXUL_LIBS"
|
||||
AC_DEFINE(MOZ_ENABLE_LIBXUL)
|
||||
|
||||
dnl ========================================================
|
||||
dnl =
|
||||
@ -8798,8 +8765,6 @@ AC_SUBST(JAR)
|
||||
|
||||
AC_SUBST(MOZ_PROFILELOCKING)
|
||||
|
||||
AC_SUBST(BUILD_STATIC_LIBS)
|
||||
AC_SUBST(MOZ_ENABLE_LIBXUL)
|
||||
AC_SUBST(ENABLE_TESTS)
|
||||
AC_SUBST(IBMBIDI)
|
||||
AC_SUBST(MOZ_UNIVERSALCHARDET)
|
||||
|
3
content/base/crashtests/658845-1.svg
Normal file
3
content/base/crashtests/658845-1.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<use xlink:href="data:" />
|
||||
</svg>
|
After Width: | Height: | Size: 120 B |
@ -90,3 +90,4 @@ load 637214-1.svg
|
||||
load 637214-2.svg
|
||||
load 642022-1.html
|
||||
load 646184.html
|
||||
load 658845-1.svg
|
||||
|
@ -124,6 +124,7 @@ XPIDLSRCS = \
|
||||
nsIContentSecurityPolicy.idl \
|
||||
nsIFrameMessageManager.idl \
|
||||
nsIWebSocket.idl \
|
||||
nsIEventSource.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -928,7 +928,7 @@ public:
|
||||
/**
|
||||
* This method creates and dispatches a trusted event.
|
||||
* Works only with events which can be created by calling
|
||||
* nsIDOMDocumentEvent::CreateEvent() with parameter "Events".
|
||||
* nsIDOMDocument::CreateEvent() with parameter "Events".
|
||||
* @param aDoc The document which will be used to create the event.
|
||||
* @param aTarget The target of the event, should be QIable to
|
||||
* nsIDOMEventTarget.
|
||||
@ -949,7 +949,7 @@ public:
|
||||
* This method creates and dispatches a trusted event to the chrome
|
||||
* event handler.
|
||||
* Works only with events which can be created by calling
|
||||
* nsIDOMDocumentEvent::CreateEvent() with parameter "Events".
|
||||
* nsIDOMDocument::CreateEvent() with parameter "Events".
|
||||
* @param aDocument The document which will be used to create the event,
|
||||
* and whose window's chrome handler will be used to
|
||||
* dispatch the event.
|
||||
|
91
content/base/public/nsIEventSource.idl
Normal file
91
content/base/public/nsIEventSource.idl
Normal file
@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* France Telecom Research and Development.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joshua Randall <jcrandall@alum.mit.edu> (original author)
|
||||
* Wellington Fernando de Macedo <wfernandom2004@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* The nsIEventSource interface is the interface for server-sent
|
||||
* DOM events as described in
|
||||
* http://dev.w3.org/html5/eventsource/#eventsource
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIPrincipal;
|
||||
interface nsIScriptContext;
|
||||
interface nsPIDOMWindow;
|
||||
|
||||
[scriptable, uuid(755e2d2d-a836-4539-83f4-16b51156341f)]
|
||||
interface nsIEventSource : nsISupports
|
||||
{
|
||||
readonly attribute DOMString url;
|
||||
|
||||
// ready state
|
||||
const unsigned short CONNECTING = 0;
|
||||
const unsigned short OPEN = 1;
|
||||
const unsigned short CLOSED = 2;
|
||||
readonly attribute long readyState;
|
||||
|
||||
// event handler attributes
|
||||
attribute nsIDOMEventListener onopen;
|
||||
attribute nsIDOMEventListener onmessage;
|
||||
attribute nsIDOMEventListener onerror;
|
||||
|
||||
/**
|
||||
* Close the connection, if any, and set the readyState attribute to CLOSED.
|
||||
* If the connection is already closed, the method does nothing.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Initialize the object for use from C++ code with the principal, script
|
||||
* context, and owner window that should be used.
|
||||
*
|
||||
* @param principal The principal to use for the request. This must not be
|
||||
* null.
|
||||
* @param scriptContext The script context to use for the request. May be
|
||||
* null.
|
||||
* @param ownerWindow The associated window for the request. May be null.
|
||||
* @param url The EventSource's url. This must not be empty.
|
||||
*/
|
||||
[noscript] void init(in nsIPrincipal principal,
|
||||
in nsIScriptContext scriptContext,
|
||||
in nsPIDOMWindow ownerWindow,
|
||||
in DOMString url);
|
||||
};
|
@ -152,6 +152,7 @@ CPPSRCS = \
|
||||
nsFrameMessageManager.cpp \
|
||||
nsInProcessTabChildGlobal.cpp \
|
||||
ThirdPartyUtil.cpp \
|
||||
nsEventSource.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Are we targeting x86-32 or x86-64? If so, we want to include SSE2 code for
|
||||
|
@ -115,7 +115,6 @@
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#ifdef MOZ_XTF
|
||||
#include "nsIXTFService.h"
|
||||
static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
@ -597,6 +596,8 @@ nsContentUtils::InitializeEventTable() {
|
||||
{ nsGkAtoms::oncopy, NS_COPY, EventNameType_HTMLXUL, NS_EVENT },
|
||||
{ nsGkAtoms::oncut, NS_CUT, EventNameType_HTMLXUL, NS_EVENT },
|
||||
{ nsGkAtoms::onpaste, NS_PASTE, EventNameType_HTMLXUL, NS_EVENT },
|
||||
{ nsGkAtoms::onopen, NS_OPEN, EventNameType_None, NS_EVENT },
|
||||
{ nsGkAtoms::onmessage, NS_MESSAGE, EventNameType_None, NS_EVENT },
|
||||
// XUL specific events
|
||||
{ nsGkAtoms::ontext, NS_TEXT_TEXT, EventNameType_XUL, NS_EVENT_NULL },
|
||||
|
||||
@ -3343,13 +3344,13 @@ nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget,
|
||||
nsIDOMEvent** aEvent,
|
||||
nsIDOMEventTarget** aTargetOut)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(aDoc));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aDoc);
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(aTarget));
|
||||
NS_ENSURE_TRUE(docEvent && target, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(domDoc && target, NS_ERROR_INVALID_ARG);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv =
|
||||
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
|
||||
@ -5528,10 +5529,10 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget,
|
||||
{
|
||||
NS_ENSURE_STATE(aTarget);
|
||||
nsIDocument* doc = aTarget->GetOwnerDoc();
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(doc);
|
||||
NS_ENSURE_STATE(docEvent);
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc);
|
||||
NS_ENSURE_STATE(domDoc);
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
docEvent->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMXULCommandEvent> xulCommand = do_QueryInterface(event);
|
||||
nsCOMPtr<nsIPrivateDOMEvent> pEvent = do_QueryInterface(xulCommand);
|
||||
|
@ -271,7 +271,7 @@ NS_IMETHODIMP
|
||||
nsDOMFileReader::Abort()
|
||||
{
|
||||
if (mReadyState != nsIDOMFileReader::LOADING)
|
||||
return NS_OK;
|
||||
return NS_ERROR_DOM_FILE_ABORT_ERR;
|
||||
|
||||
//Clear progress and file data
|
||||
mProgressEventWasDelayed = PR_FALSE;
|
||||
|
@ -1685,7 +1685,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsDocument)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3DocumentEvent)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentStyle)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocumentStyle)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL)
|
||||
@ -4130,13 +4129,12 @@ nsDocument::DispatchContentLoadedEvents()
|
||||
if (target_frame) {
|
||||
nsCOMPtr<nsIDocument> parent = mParentDocument;
|
||||
do {
|
||||
nsCOMPtr<nsIDOMDocumentEvent> document_event =
|
||||
do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(parent);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent;
|
||||
if (document_event) {
|
||||
document_event->CreateEvent(NS_LITERAL_STRING("Events"),
|
||||
if (domDoc) {
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("Events"),
|
||||
getter_AddRefs(event));
|
||||
|
||||
privateEvent = do_QueryInterface(event);
|
||||
@ -6360,19 +6358,6 @@ nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
|
||||
aEventType, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::CreateEventGroup(nsIDOMEventGroup **aInstancePtrResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMEventGroup> group(do_CreateInstance(kDOMEventGroupCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aInstancePtrResult = group;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::FlushPendingNotifications(mozFlushType aType)
|
||||
{
|
||||
|
@ -69,8 +69,6 @@
|
||||
#include "nsIParser.h"
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOM3DocumentEvent.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsIBoxObject.h"
|
||||
@ -493,8 +491,6 @@ protected:
|
||||
class nsDocument : public nsIDocument,
|
||||
public nsIDOMXMLDocument, // inherits nsIDOMDocument
|
||||
public nsIDOMNSDocument,
|
||||
public nsIDOMDocumentEvent,
|
||||
public nsIDOM3DocumentEvent,
|
||||
public nsIDOMNSDocumentStyle,
|
||||
public nsIDOMDocumentXBL,
|
||||
public nsSupportsWeakReference,
|
||||
@ -798,12 +794,6 @@ public:
|
||||
// nsIDOMNSDocument
|
||||
NS_DECL_NSIDOMNSDOCUMENT
|
||||
|
||||
// nsIDOMDocumentEvent
|
||||
NS_DECL_NSIDOMDOCUMENTEVENT
|
||||
|
||||
// nsIDOM3DocumentEvent
|
||||
NS_DECL_NSIDOM3DOCUMENTEVENT
|
||||
|
||||
// nsIDOMDocumentStyle
|
||||
NS_DECL_NSIDOMDOCUMENTSTYLE
|
||||
|
||||
@ -1252,7 +1242,6 @@ protected:
|
||||
NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
||||
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument) \
|
||||
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument) \
|
||||
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentEvent, nsDocument) \
|
||||
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument) \
|
||||
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)
|
||||
|
||||
|
1656
content/base/src/nsEventSource.cpp
Executable file
1656
content/base/src/nsEventSource.cpp
Executable file
File diff suppressed because it is too large
Load Diff
267
content/base/src/nsEventSource.h
Executable file
267
content/base/src/nsEventSource.h
Executable file
@ -0,0 +1,267 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Wellington Fernando de Macedo.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Wellington Fernando de Macedo <wfernandom2004@gmail.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This implementation has support only for http requests. It is because the
|
||||
* spec has defined event streams only for http. HTTP is required because
|
||||
* this implementation uses some http headers: "Last-Event-ID", "Cache-Control"
|
||||
* and "Accept".
|
||||
*/
|
||||
|
||||
#ifndef nsEventSource_h__
|
||||
#define nsEventSource_h__
|
||||
|
||||
#include "nsIEventSource.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "nsDOMEventTargetWrapperCache.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
#define NS_EVENTSOURCE_CID \
|
||||
{ /* 755e2d2d-a836-4539-83f4-16b51156341f */ \
|
||||
0x755e2d2d, 0xa836, 0x4539, \
|
||||
{0x83, 0xf4, 0x16, 0xb5, 0x11, 0x56, 0x34, 0x1f} }
|
||||
|
||||
#define NS_EVENTSOURCE_CONTRACTID "@mozilla.org/eventsource;1"
|
||||
|
||||
class AsyncVerifyRedirectCallbackFwr;
|
||||
class nsAutoClearFields;
|
||||
|
||||
class nsEventSource: public nsDOMEventTargetWrapperCache,
|
||||
public nsIEventSource,
|
||||
public nsIJSNativeInitializer,
|
||||
public nsIObserver,
|
||||
public nsIStreamListener,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class AsyncVerifyRedirectCallbackFwr;
|
||||
|
||||
public:
|
||||
nsEventSource();
|
||||
virtual ~nsEventSource();
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsEventSource,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
|
||||
NS_DECL_NSIEVENTSOURCE
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
|
||||
PRUint32 argc, jsval* argv);
|
||||
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// Determine if preferences allow EventSource
|
||||
static PRBool PrefEnabled();
|
||||
|
||||
protected:
|
||||
nsresult GetBaseURI(nsIURI **aBaseURI);
|
||||
|
||||
nsresult SetupHttpChannel();
|
||||
nsresult InitChannelAndRequestEventSource();
|
||||
nsresult ResetConnection();
|
||||
nsresult DispatchFailConnection();
|
||||
nsresult SetReconnectionTimeout();
|
||||
|
||||
void AnnounceConnection();
|
||||
void DispatchAllMessageEvents();
|
||||
void ReestablishConnection();
|
||||
void FailConnection();
|
||||
|
||||
nsresult Thaw();
|
||||
nsresult Freeze();
|
||||
|
||||
static void TimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
nsresult PrintErrorOnConsole(const char *aBundleURI,
|
||||
const PRUnichar *aError,
|
||||
const PRUnichar **aFormatStrings,
|
||||
PRUint32 aFormatStringsLen);
|
||||
nsresult ConsoleError();
|
||||
|
||||
static NS_METHOD StreamReaderFunc(nsIInputStream *aInputStream,
|
||||
void *aClosure,
|
||||
const char *aFromRawSegment,
|
||||
PRUint32 aToOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aWriteCount);
|
||||
nsresult SetFieldAndClear();
|
||||
nsresult ClearFields();
|
||||
nsresult ResetEvent();
|
||||
nsresult DispatchCurrentMessageEvent();
|
||||
nsresult ParseCharacter(PRUnichar aChr);
|
||||
PRBool CheckCanRequestSrc(nsIURI* aSrc = nsnull); // if null, it tests mSrc
|
||||
nsresult CheckHealthOfRequestCallback(nsIRequest *aRequestCallback);
|
||||
nsresult OnRedirectVerifyCallback(nsresult result);
|
||||
|
||||
nsCOMPtr<nsIURI> mSrc;
|
||||
|
||||
nsString mLastEventID;
|
||||
PRUint32 mReconnectionTime; // in ms
|
||||
|
||||
struct Message {
|
||||
nsString mEventName;
|
||||
nsString mLastEventID;
|
||||
nsString mData;
|
||||
};
|
||||
nsDeque mMessagesToDispatch;
|
||||
Message mCurrentMessage;
|
||||
|
||||
/**
|
||||
* A simple state machine used to manage the event-source's line buffer
|
||||
*
|
||||
* PARSE_STATE_OFF -> PARSE_STATE_BEGIN_OF_STREAM
|
||||
*
|
||||
* PARSE_STATE_BEGIN_OF_STREAM -> PARSE_STATE_BOM_WAS_READ |
|
||||
* PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE |
|
||||
* PARSE_STATE_COMMENT |
|
||||
* PARSE_STATE_FIELD_NAME
|
||||
*
|
||||
* PARSE_STATE_BOM_WAS_READ -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE |
|
||||
* PARSE_STATE_COMMENT |
|
||||
* PARSE_STATE_FIELD_NAME
|
||||
*
|
||||
* PARSE_STATE_CR_CHAR -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_COMMENT |
|
||||
* PARSE_STATE_FIELD_NAME |
|
||||
* PARSE_STATE_BEGIN_OF_LINE
|
||||
*
|
||||
* PARSE_STATE_COMMENT -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE
|
||||
*
|
||||
* PARSE_STATE_FIELD_NAME -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE |
|
||||
* PARSE_STATE_FIRST_CHAR_OF_FIELD_VALUE
|
||||
*
|
||||
* PARSE_STATE_FIRST_CHAR_OF_FIELD_VALUE -> PARSE_STATE_FIELD_VALUE |
|
||||
* PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE
|
||||
*
|
||||
* PARSE_STATE_FIELD_VALUE -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_BEGIN_OF_LINE
|
||||
*
|
||||
* PARSE_STATE_BEGIN_OF_LINE -> PARSE_STATE_CR_CHAR |
|
||||
* PARSE_STATE_COMMENT |
|
||||
* PARSE_STATE_FIELD_NAME |
|
||||
* PARSE_STATE_BEGIN_OF_LINE
|
||||
*
|
||||
* Whenever the parser find an empty line or the end-of-file
|
||||
* it dispatches the stacked event.
|
||||
*
|
||||
*/
|
||||
enum ParserStatus {
|
||||
PARSE_STATE_OFF,
|
||||
PARSE_STATE_BEGIN_OF_STREAM,
|
||||
PARSE_STATE_BOM_WAS_READ,
|
||||
PARSE_STATE_CR_CHAR,
|
||||
PARSE_STATE_COMMENT,
|
||||
PARSE_STATE_FIELD_NAME,
|
||||
PARSE_STATE_FIRST_CHAR_OF_FIELD_VALUE,
|
||||
PARSE_STATE_FIELD_VALUE,
|
||||
PARSE_STATE_BEGIN_OF_LINE
|
||||
};
|
||||
ParserStatus mStatus;
|
||||
|
||||
PRPackedBool mFrozen;
|
||||
PRPackedBool mErrorLoadOnRedirect;
|
||||
PRPackedBool mGoingToDispatchAllMessages;
|
||||
|
||||
// used while reading the input streams
|
||||
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
||||
nsresult mLastConvertionResult;
|
||||
nsString mLastFieldName;
|
||||
nsString mLastFieldValue;
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnOpenListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnMessageListener;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
||||
/**
|
||||
* The notification callbacks the channel had initially.
|
||||
* We want to forward things here as needed.
|
||||
*/
|
||||
nsCOMPtr<nsIInterfaceRequestor> mNotificationCallbacks;
|
||||
nsCOMPtr<nsIChannelEventSink> mChannelEventSink;
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> mHttpChannel;
|
||||
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
PRInt32 mReadyState;
|
||||
nsString mOriginalURL;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsCString mOrigin;
|
||||
|
||||
PRUint32 mRedirectFlags;
|
||||
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
|
||||
nsCOMPtr<nsIChannel> mNewRedirectChannel;
|
||||
|
||||
// Event Source owner information:
|
||||
// - the script file name
|
||||
// - source code line number where the Event Source object was constructed.
|
||||
// - the window ID of the outer window where the script lives. Note that this
|
||||
// may not be the same as the Event Source owner window.
|
||||
// These attributes are used for error reporting.
|
||||
nsString mScriptFile;
|
||||
PRUint32 mScriptLine;
|
||||
PRUint64 mWindowID;
|
||||
|
||||
private:
|
||||
nsEventSource(const nsEventSource& x); // prevent bad usage
|
||||
nsEventSource& operator=(const nsEventSource& x);
|
||||
};
|
||||
|
||||
#endif // nsEventSource_h__
|
@ -692,6 +692,7 @@ GK_ATOM(onLoad, "onLoad")
|
||||
GK_ATOM(onload, "onload")
|
||||
GK_ATOM(onpopstate, "onpopstate")
|
||||
GK_ATOM(only, "only") // this one is not an event
|
||||
GK_ATOM(onmessage, "onmessage")
|
||||
GK_ATOM(onmousedown, "onmousedown")
|
||||
GK_ATOM(onmousemove, "onmousemove")
|
||||
GK_ATOM(onmouseout, "onmouseout")
|
||||
@ -704,6 +705,7 @@ GK_ATOM(onMozMousePixelScroll, "onMozMousePixelScroll")
|
||||
GK_ATOM(onMozScrolledAreaChanged, "onMozScrolledAreaChanged")
|
||||
GK_ATOM(ononline, "ononline")
|
||||
GK_ATOM(onoffline, "onoffline")
|
||||
GK_ATOM(onopen, "onopen")
|
||||
GK_ATOM(onoverflow, "onoverflow")
|
||||
GK_ATOM(onoverflowchanged, "onoverflowchanged")
|
||||
GK_ATOM(onpagehide, "onpagehide")
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDataContainerEvent.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIExternalProtocolHandler.h"
|
||||
#include "nsEventStates.h"
|
||||
@ -257,15 +257,15 @@ nsPluginCrashedEvent::Run()
|
||||
LOG(("OBJLC []: Firing plugin crashed event for content %p\n",
|
||||
mContent.get()));
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentEvent> domEventDoc =
|
||||
nsCOMPtr<nsIDOMDocument> domDoc =
|
||||
do_QueryInterface(mContent->GetDocument());
|
||||
if (!domEventDoc) {
|
||||
if (!domDoc) {
|
||||
NS_WARNING("Couldn't get document for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
domEventDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
|
||||
nsCOMPtr<nsIDOMDataContainerEvent> containerEvent(do_QueryInterface(event));
|
||||
|
@ -52,10 +52,12 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
|
||||
PRBool aWatch, PRBool aReferenceImage)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aFromContent, "Reset() expects non-null content pointer");
|
||||
NS_ABORT_IF_FALSE(aURI, "Reset() expects non-null URI for referenced elem");
|
||||
|
||||
Unlink();
|
||||
|
||||
if (!aURI)
|
||||
return;
|
||||
|
||||
nsCAutoString refPart;
|
||||
aURI->GetRef(refPart);
|
||||
// Unescape %-escapes in the reference. The result will be in the
|
||||
|
@ -39,6 +39,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsWebSocket.h"
|
||||
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -57,7 +58,6 @@
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMMessageEvent.h"
|
||||
#include "nsIPromptFactory.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
@ -819,6 +819,31 @@ nsWebSocket::CreateAndDispatchMessageEvent(const nsACString& aData)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Let's play get the JSContext
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(mOwner);
|
||||
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
|
||||
|
||||
nsIScriptContext* scriptContext = sgo->GetContext();
|
||||
NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
|
||||
|
||||
JSContext* cx = (JSContext*)scriptContext->GetNativeContext();
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
||||
|
||||
// Now we can turn our string into a jsval
|
||||
|
||||
jsval jsData;
|
||||
{
|
||||
NS_ConvertUTF8toUTF16 utf16Data(aData);
|
||||
JSString* jsString;
|
||||
JSAutoRequest ar(cx);
|
||||
jsString = JS_NewUCStringCopyN(cx,
|
||||
utf16Data.get(),
|
||||
utf16Data.Length());
|
||||
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
|
||||
|
||||
jsData = STRING_TO_JSVAL(jsString);
|
||||
}
|
||||
|
||||
// create an event that uses the MessageEvent interface,
|
||||
// which does not bubble, is not cancelable, and has no default action
|
||||
|
||||
@ -829,7 +854,7 @@ nsWebSocket::CreateAndDispatchMessageEvent(const nsACString& aData)
|
||||
nsCOMPtr<nsIDOMMessageEvent> messageEvent = do_QueryInterface(event);
|
||||
rv = messageEvent->InitMessageEvent(NS_LITERAL_STRING("message"),
|
||||
PR_FALSE, PR_FALSE,
|
||||
NS_ConvertUTF8toUTF16(aData),
|
||||
jsData,
|
||||
mUTF16Origin,
|
||||
EmptyString(), nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -483,6 +483,26 @@ _TEST_FILES2 = \
|
||||
test_bug656283.html \
|
||||
test_blobbuilder.html \
|
||||
fileutils.js \
|
||||
test_bug338583.html \
|
||||
eventsource.resource \
|
||||
eventsource.resource^headers^ \
|
||||
badContentType.eventsource \
|
||||
badContentType.eventsource^headers^ \
|
||||
badEventFieldName.eventsource \
|
||||
badEventFieldName.eventsource^headers^ \
|
||||
badHTTPResponseCode.eventsource \
|
||||
badHTTPResponseCode.eventsource^headers^ \
|
||||
badMessageEvent.eventsource \
|
||||
badMessageEvent.eventsource^headers^ \
|
||||
forRemoval.resource \
|
||||
forRemoval.resource^headers^ \
|
||||
accesscontrol.resource \
|
||||
accesscontrol.resource^headers^ \
|
||||
invalid_accesscontrol.resource \
|
||||
invalid_accesscontrol.resource^headers^ \
|
||||
somedatas.resource \
|
||||
somedatas.resource^headers^ \
|
||||
delayedServerEvents.sjs \
|
||||
$(NULL)
|
||||
|
||||
# This test fails on the Mac for some reason
|
||||
|
5
content/base/test/accesscontrol.resource
Normal file
5
content/base/test/accesscontrol.resource
Normal file
@ -0,0 +1,5 @@
|
||||
:this file must be enconded in utf8
|
||||
:and its Content-Type must be equal to text/event-stream
|
||||
|
||||
event: message
|
||||
data: 1
|
4
content/base/test/accesscontrol.resource^headers^
Normal file
4
content/base/test/accesscontrol.resource^headers^
Normal file
@ -0,0 +1,4 @@
|
||||
Access-Control-Allow-Origin: http://localhost:8888
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
3
content/base/test/badContentType.eventsource
Normal file
3
content/base/test/badContentType.eventsource
Normal file
@ -0,0 +1,3 @@
|
||||
retry:500
|
||||
event: message
|
||||
data: 1
|
1
content/base/test/badContentType.eventsource^headers^
Normal file
1
content/base/test/badContentType.eventsource^headers^
Normal file
@ -0,0 +1 @@
|
||||
Content-Type: text/plain
|
4
content/base/test/badEventFieldName.eventsource
Normal file
4
content/base/test/badEventFieldName.eventsource
Normal file
@ -0,0 +1,4 @@
|
||||
retry:500
|
||||
:space isn't a valid NCName char, am I right?
|
||||
event: message event
|
||||
data: 1
|
1
content/base/test/badEventFieldName.eventsource^headers^
Normal file
1
content/base/test/badEventFieldName.eventsource^headers^
Normal file
@ -0,0 +1 @@
|
||||
Content-Type: text/event-stream
|
3
content/base/test/badHTTPResponseCode.eventsource
Normal file
3
content/base/test/badHTTPResponseCode.eventsource
Normal file
@ -0,0 +1,3 @@
|
||||
retry:500
|
||||
event: message
|
||||
data: 1
|
@ -0,0 +1,2 @@
|
||||
HTTP 404 Not Found
|
||||
Content-Type: text/event-stream
|
2
content/base/test/badMessageEvent.eventsource
Normal file
2
content/base/test/badMessageEvent.eventsource
Normal file
@ -0,0 +1,2 @@
|
||||
retry:500
|
||||
event: message
|
1
content/base/test/badMessageEvent.eventsource^headers^
Normal file
1
content/base/test/badMessageEvent.eventsource^headers^
Normal file
@ -0,0 +1 @@
|
||||
Content-Type: text/event-stream
|
42
content/base/test/delayedServerEvents.sjs
Normal file
42
content/base/test/delayedServerEvents.sjs
Normal file
@ -0,0 +1,42 @@
|
||||
// this will take strings_to_send.length*5000 ms = 50 sec
|
||||
|
||||
var timer = null;
|
||||
var strings_to_send = ["data\r\n\nda", "ta", ":", "de", "layed1\n\n",
|
||||
"",
|
||||
"",
|
||||
"data:delayed2", "", ""];
|
||||
var resp = null;
|
||||
|
||||
function sendNextString()
|
||||
{
|
||||
if (strings_to_send.length == 0) {
|
||||
timer.cancel();
|
||||
resp.finish();
|
||||
timer = null;
|
||||
resp = null;
|
||||
return;
|
||||
}
|
||||
|
||||
resp.write(strings_to_send[0]);
|
||||
strings_to_send = strings_to_send.splice(1, strings_to_send.length - 1);
|
||||
}
|
||||
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var b = 0;
|
||||
for (var i=0; i < strings_to_send.length; ++i) {
|
||||
b += strings_to_send[i].length;
|
||||
}
|
||||
|
||||
response.seizePower();
|
||||
response.write("HTTP/1.1 200 OK\r\n")
|
||||
response.write("Content-Length: " + b + "\r\n");
|
||||
response.write("Content-Type: text/event-stream; charset=utf-8\r\n");
|
||||
response.write("Cache-Control: no-cache, must-revalidate\r\n");
|
||||
response.write("\r\n");
|
||||
|
||||
resp = response;
|
||||
|
||||
timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
|
||||
timer.initWithCallback(sendNextString, 5000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
}
|
20
content/base/test/eventsource.resource
Normal file
20
content/base/test/eventsource.resource
Normal file
@ -0,0 +1,20 @@
|
||||
:this file must be enconded in utf8
|
||||
:and its Content-Type must be equal to text/event-stream
|
||||
|
||||
retry:500
|
||||
data: 1
|
||||
unknow: unknow
|
||||
|
||||
event: other_event_name
|
||||
retry:500
|
||||
data: 1
|
||||
unknow: unknow
|
||||
|
||||
event: click
|
||||
retry:500
|
||||
|
||||
event: blur
|
||||
retry:500
|
||||
|
||||
event:keypress
|
||||
retry:500
|
3
content/base/test/eventsource.resource^headers^
Normal file
3
content/base/test/eventsource.resource^headers^
Normal file
@ -0,0 +1,3 @@
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
23
content/base/test/forRemoval.resource
Normal file
23
content/base/test/forRemoval.resource
Normal file
@ -0,0 +1,23 @@
|
||||
:this file must be enconded in utf8
|
||||
:and its Content-Type must be equal to text/event-stream
|
||||
|
||||
retry:500
|
||||
event: message
|
||||
data: 1
|
||||
|
||||
retry:500
|
||||
event: message
|
||||
data: 2
|
||||
|
||||
retry:500
|
||||
event: message
|
||||
data: 3
|
||||
|
||||
retry:500
|
||||
event: message
|
||||
data: 4
|
||||
|
||||
retry:500
|
||||
event: message
|
||||
data: 5
|
||||
|
3
content/base/test/forRemoval.resource^headers^
Normal file
3
content/base/test/forRemoval.resource^headers^
Normal file
@ -0,0 +1,3 @@
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
5
content/base/test/invalid_accesscontrol.resource
Normal file
5
content/base/test/invalid_accesscontrol.resource
Normal file
@ -0,0 +1,5 @@
|
||||
:this file must be enconded in utf8
|
||||
:and its Content-Type must be equal to text/event-stream
|
||||
|
||||
event: message
|
||||
data: 1
|
@ -0,0 +1,4 @@
|
||||
Access-Control-Allow-Origin: http://an.accesscrontrol.domain:80
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
17
content/base/test/somedatas.resource
Normal file
17
content/base/test/somedatas.resource
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
retry: 500
|
||||
|
||||
data:123456789
|
||||
data: 123456789123456789
|
||||
data:123456789123456789123456789123456789
|
||||
data: 123456789123456789123456789123456789123456789123456789123456789123456789
|
||||
:some utf-8 characteres
|
||||
data:çãá"'@`~Ý Ḿyyyy
|
||||
|
||||
:test if the character ":"(which is used for comments) isn't misunderstood
|
||||
data: :xxabcdefghij
|
||||
data:çãá"'@`~Ý Ḿyyyy : zz
|
||||
|
||||
:a message dispatched because of eof
|
||||
data:1
|
3
content/base/test/somedatas.resource^headers^
Normal file
3
content/base/test/somedatas.resource^headers^
Normal file
@ -0,0 +1,3 @@
|
||||
Content-Type: text/event-stream
|
||||
Cache-Control: no-cache, must-revalidate
|
||||
|
454
content/base/test/test_bug338583.html
Executable file
454
content/base/test/test_bug338583.html
Executable file
@ -0,0 +1,454 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=338583
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
||||
<title>Test for Bug 338583</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
</head>
|
||||
<body bgColor=white>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=338583">Mozilla Bug 338583</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 338583 **/
|
||||
|
||||
// we test:
|
||||
// 1) the EventSource behaviour
|
||||
// 2) if the events are trusted
|
||||
// 3) possible invalid eventsources
|
||||
// 4) the close method when the object is just been used
|
||||
// 5) access-control
|
||||
// 6) the data parameter
|
||||
// 7) delayed server responses
|
||||
|
||||
// --
|
||||
|
||||
function fn_onmessage(e) {
|
||||
if (e.currentTarget == e.target && e.target.hits != null)
|
||||
e.target.hits['fn_onmessage']++;
|
||||
}
|
||||
|
||||
function fn_event_listener_message(e) {
|
||||
if (e.currentTarget == e.target && e.target.hits != null)
|
||||
e.target.hits['fn_event_listener_message']++;
|
||||
}
|
||||
|
||||
function fn_other_event_name(e) {
|
||||
if (e.currentTarget == e.target && e.target.hits != null)
|
||||
e.target.hits['fn_other_event_name']++;
|
||||
}
|
||||
|
||||
var domBranch;
|
||||
var oldPrefVal;
|
||||
|
||||
var gEventSourceObj1 = null;
|
||||
var gEventSourceObj2 = null;
|
||||
var gEventSourceObj3 = null;
|
||||
var gEventSourceObj4 = null;
|
||||
var gEventSourceObj5 = null;
|
||||
var gEventSourceObj6 = null;
|
||||
var gEventSourceObj7 = null;
|
||||
var stress_factor; // used in the setTimeouts in order to help
|
||||
// the test when running in slow machines
|
||||
|
||||
function hasBeenHitFor1And2(obj, min) {
|
||||
if (obj.hits['fn_onmessage'] < min ||
|
||||
obj.hits['fn_event_listener_message'] < min ||
|
||||
obj.hits['fn_other_event_name'] < min)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// in order to test (1):
|
||||
// a) if the EventSource constructor parameter is equal to its url attribute
|
||||
// b) let its fn_onmessage, fn_event_listener_message, and fn_other_event_name functions listeners be hit four times each
|
||||
// c) the close method (we expect readyState == CLOSED)
|
||||
// d) the close method (we expect no message events anymore)
|
||||
|
||||
function doTest1() {
|
||||
gEventSourceObj1 = new EventSource("eventsource.resource");
|
||||
ok(gEventSourceObj1.url == "http://mochi.test:8888/tests/content/base/test/eventsource.resource", "Test 1.a failed.");
|
||||
ok(gEventSourceObj1.readyState == 0 || gEventSourceObj1.readyState == 1, "Test 1.a failed.");
|
||||
|
||||
doTest1_b();
|
||||
}
|
||||
|
||||
function doTest1_b() {
|
||||
gEventSourceObj1.hits = [];
|
||||
gEventSourceObj1.hits['fn_onmessage'] = 0;
|
||||
gEventSourceObj1.onmessage = fn_onmessage;
|
||||
gEventSourceObj1.hits['fn_event_listener_message'] = 0;
|
||||
gEventSourceObj1.addEventListener('message', fn_event_listener_message, true);
|
||||
gEventSourceObj1.hits['fn_other_event_name'] = 0;
|
||||
gEventSourceObj1.addEventListener('other_event_name', fn_other_event_name, true);
|
||||
|
||||
// the eventsources.res always use a retry of 0.5 second, so for four hits a timeout of 3 seconds is enough
|
||||
setTimeout(function(){
|
||||
bhits = hasBeenHitFor1And2(gEventSourceObj1, 4);
|
||||
ok(bhits, "Test 1.b failed.");
|
||||
|
||||
doTest1_c();
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest1_c() {
|
||||
gEventSourceObj1.close();
|
||||
ok(gEventSourceObj1.readyState == 2, "Test 1.c failed.");
|
||||
|
||||
doTest1_d();
|
||||
}
|
||||
|
||||
function doTest1_d() {
|
||||
gEventSourceObj1.hits['fn_onmessage'] = 0;
|
||||
gEventSourceObj1.hits['fn_event_listener_message'] = 0;
|
||||
gEventSourceObj1.hits['fn_other_event_name'] = 0;
|
||||
|
||||
setTimeout(function(){
|
||||
bhits = hasBeenHitFor1And2(gEventSourceObj1, 1);
|
||||
ok(!bhits, "Test 1.d failed.");
|
||||
gEventSourceObj1.close();
|
||||
|
||||
doTest2();
|
||||
}, parseInt(2000*stress_factor));
|
||||
}
|
||||
|
||||
// in order to test (2)
|
||||
// a) set a eventsource that give the dom events messages
|
||||
// b) expect trusted events
|
||||
|
||||
function doTest2() {
|
||||
var func = function(e) {
|
||||
ok(e.isTrusted, "Test 2 failed");
|
||||
gEventSourceObj2.close();
|
||||
};
|
||||
|
||||
gEventSourceObj2 = new EventSource("eventsource.resource");
|
||||
gEventSourceObj2.onmessage = func;
|
||||
|
||||
setTimeout(function(){ // just to clean...
|
||||
gEventSourceObj2.close();
|
||||
}, parseInt(5000*stress_factor));
|
||||
|
||||
doTest3();
|
||||
}
|
||||
|
||||
// in order to test (3)
|
||||
// a) XSite domain error test
|
||||
// b) protocol file:/// test
|
||||
// c) protocol javascript: test
|
||||
// d) wrong Content-Type test
|
||||
// e) bad http response code test
|
||||
// f) message eventsource without a data test
|
||||
// g) eventsource with invalid NCName char in the event field test
|
||||
// h) DNS error
|
||||
|
||||
function doTest3() {
|
||||
gEventSourceObj3 = new EventSource("http://example.org/tests/content/base/test/eventsource.resource");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.a failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_b();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_b() {
|
||||
gEventSourceObj3 = new EventSource("file:///home/wellington/src/content/base/test/eventsource.resource");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.b failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_c();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function jsEvtSource()
|
||||
{
|
||||
return "event: message\n" +
|
||||
"data: 1\n\n";
|
||||
}
|
||||
|
||||
function doTest3_c() {
|
||||
gEventSourceObj3 = new EventSource("javascript: return jsEvtSource()");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.c failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_d();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_d() {
|
||||
gEventSourceObj3 = new EventSource("badContentType.eventsource");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.d failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_e();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_e() {
|
||||
gEventSourceObj3 = new EventSource("badHTTPResponseCode.eventsource");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.e failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_f();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_f() {
|
||||
gEventSourceObj3 = new EventSource("badMessageEvent.eventsource");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.f failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_g();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function fnInvalidNCName() {
|
||||
fnInvalidNCName.hits++;
|
||||
}
|
||||
|
||||
function doTest3_g() {
|
||||
gEventSourceObj3 = new EventSource("badEventFieldName.eventsource");
|
||||
|
||||
fnInvalidNCName.hits = 0;
|
||||
gEventSourceObj3.addEventListener('message event', fnInvalidNCName, true);
|
||||
|
||||
setTimeout(function() {
|
||||
ok(fnInvalidNCName.hits != 0, "Test 3.g failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest3_h();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest3_h() {
|
||||
gEventSourceObj3 = new EventSource("http://hdfskjghsbg.jtiyoejowe.dafsgbhjab.com");
|
||||
|
||||
gEventSourceObj3.onmessage = fn_onmessage;
|
||||
gEventSourceObj3.hits = [];
|
||||
gEventSourceObj3.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj3.hits['fn_onmessage'] == 0, "Test 3.h failed");
|
||||
gEventSourceObj3.close();
|
||||
|
||||
doTest4();
|
||||
}, parseInt(1500*stress_factor));
|
||||
}
|
||||
|
||||
// in order to test (4)
|
||||
// a) close the object when it is in use, which is being processed and that is expected
|
||||
// to dispatch more eventlisteners
|
||||
// b) remove an eventlistener in use
|
||||
|
||||
function fn_onmessage4_a(e)
|
||||
{
|
||||
if (e.data > gEventSourceObj4.lastData)
|
||||
gEventSourceObj4.lastData = e.data;
|
||||
if (e.data == 2)
|
||||
gEventSourceObj4.close();
|
||||
}
|
||||
|
||||
function fn_onmessage4_b(e)
|
||||
{
|
||||
if (e.data > gEventSourceObj4.lastData)
|
||||
gEventSourceObj4.lastData = e.data;
|
||||
if (e.data == 2)
|
||||
gEventSourceObj4.removeEventListener('message', fn_onmessage4_b, true);
|
||||
}
|
||||
|
||||
function doTest4() {
|
||||
gEventSourceObj4 = new EventSource("forRemoval.resource");
|
||||
gEventSourceObj4.lastData = 0;
|
||||
gEventSourceObj4.onmessage = fn_onmessage4_a;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj4.lastData == 2, "Test 4.a failed");
|
||||
gEventSourceObj4.close();
|
||||
|
||||
doTest4_b();
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest4_b()
|
||||
{
|
||||
gEventSourceObj4 = new EventSource("forRemoval.resource");
|
||||
gEventSourceObj4.lastData = 0;
|
||||
gEventSourceObj4.addEventListener('message', fn_onmessage4_b, true);
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj4.lastData == 2, "Test 4.b failed");
|
||||
gEventSourceObj4.close();
|
||||
|
||||
doTest5();
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
// in order to test (5)
|
||||
// a) valid access-control xsite request (but must fail)
|
||||
// b) invalid access-control xsite request
|
||||
|
||||
function doTest5()
|
||||
{
|
||||
gEventSourceObj5 = new EventSource("http://example.org/tests/content/base/test/accesscontrol.resource");
|
||||
|
||||
gEventSourceObj5.onmessage = fn_onmessage;
|
||||
gEventSourceObj5.hits = [];
|
||||
gEventSourceObj5.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5.hits['fn_onmessage'] == 0, "Test 5.a failed");
|
||||
gEventSourceObj5.close();
|
||||
|
||||
doTest5_b();
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest5_b()
|
||||
{
|
||||
gEventSourceObj5 = new EventSource("http://example.org/tests/content/base/test/invalid_accesscontrol.resource");
|
||||
|
||||
gEventSourceObj5.onmessage = fn_onmessage;
|
||||
gEventSourceObj5.hits = [];
|
||||
gEventSourceObj5.hits['fn_onmessage'] = 0;
|
||||
|
||||
setTimeout(function() {
|
||||
ok(gEventSourceObj5.hits['fn_onmessage'] == 0, "Test 5.b failed");
|
||||
gEventSourceObj5.close();
|
||||
|
||||
doTest6();
|
||||
}, parseInt(3000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest6()
|
||||
{
|
||||
gEventSourceObj6 = new EventSource("somedatas.resource");
|
||||
var fn_somedata = function(e) {
|
||||
if (fn_somedata.expected == 0) {
|
||||
ok(e.data == "123456789\n123456789123456789\n123456789123456789123456789123456789\n 123456789123456789123456789123456789123456789123456789123456789123456789\nçãá\"\'@`~Ý Ḿyyyy",
|
||||
"Test 6.a failed");
|
||||
} else if (fn_somedata.expected == 1) {
|
||||
ok(e.data == " :xxabcdefghij\nçãá\"\'@`~Ý Ḿyyyy : zz",
|
||||
"Test 6.b failed");
|
||||
} else if (fn_somedata.expected == 2) {
|
||||
ok(e.data == "1", "Test 6.c failed");
|
||||
gEventSourceObj6.close();
|
||||
} else {
|
||||
ok(false, "Test 6 failed (unexpected message event)");
|
||||
}
|
||||
fn_somedata.expected++;
|
||||
}
|
||||
fn_somedata.expected = 0;
|
||||
gEventSourceObj6.onmessage = fn_somedata;
|
||||
|
||||
setTimeout(function() {
|
||||
gEventSourceObj6.close();
|
||||
|
||||
doTest7();
|
||||
}, parseInt(2500*stress_factor));
|
||||
}
|
||||
|
||||
function doTest7()
|
||||
{
|
||||
gEventSourceObj7 = new EventSource("delayedServerEvents.sjs");
|
||||
gEventSourceObj7.msg_received = [];
|
||||
gEventSourceObj7.onmessage = function(e)
|
||||
{
|
||||
e.target.msg_received.push(e.data);
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
gEventSourceObj7.close();
|
||||
|
||||
ok(gEventSourceObj7.msg_received[0] == "" &&
|
||||
gEventSourceObj7.msg_received[1] == "delayed1" &&
|
||||
gEventSourceObj7.msg_received[2] == "delayed2", "Test 7 failed");
|
||||
|
||||
SpecialPowers.setBoolPref("dom.server-events.enabled", oldPrefVal);
|
||||
document.getElementById('waitSpan').innerHTML = '';
|
||||
SimpleTest.finish();
|
||||
}, parseInt(50000*stress_factor));
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
oldPrefVal = SpecialPowers.getBoolPref("dom.server-events.enabled");
|
||||
SpecialPowers.setBoolPref("dom.server-events.enabled", true);
|
||||
|
||||
// we get a good stress_factor by testing 10 setTimeouts and some float
|
||||
// arithmetic taking my machine as stress_factor==1 (time=589)
|
||||
|
||||
var begin_time = (new Date()).getTime();
|
||||
|
||||
var f = function() {
|
||||
for (var j=0; j<f.i; ++j)
|
||||
eval("Math.log(Math.atan(Math.sqrt(Math.pow(3.1415, 13.1415))/0.0007))");
|
||||
if (f.i < 10) {
|
||||
f.i++;
|
||||
setTimeout(f, 10 + 10*f.i);
|
||||
} else {
|
||||
stress_factor = ((new Date()).getTime()-begin_time)*1/589;
|
||||
stress_factor *= 1.10; // also, a margin of 10%
|
||||
|
||||
doTest1();
|
||||
}
|
||||
}
|
||||
f.i = 0;
|
||||
|
||||
setTimeout(f, 10);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<span id=waitSpan>Wait please...</span>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -23,10 +23,10 @@ var gen = runTest();
|
||||
function runTest() {
|
||||
var iframe = $('iframe');
|
||||
iframe.src = "http://noxul.example.com/tests/content/base/test/file_bug590870.html";
|
||||
is((yield), "true", "shouldn't be able to create XUL elements");
|
||||
is((yield), true, "shouldn't be able to create XUL elements");
|
||||
|
||||
iframe.src = "file_bug590870.html";
|
||||
is((yield), "false", "should be able to create XUL elements");
|
||||
is((yield), false, "should be able to create XUL elements");
|
||||
|
||||
SimpleTest.finish();
|
||||
yield;
|
||||
|
@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=601803
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
window.onmessage = function (event) {
|
||||
is(event.data, "false", "Shouldn't throw when adopting a node cross-compartment");
|
||||
is(event.data, false, "Shouldn't throw when adopting a node cross-compartment");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,13 @@ r.onloadend = function (event) {
|
||||
r.onload = function() { ok(false, "load should not fire for aborted reads") };
|
||||
r.onerror = function() { ok(false, "error should not fire for aborted reads") };
|
||||
r.onprogress = function() { ok(false, "progress should not fire for aborted reads") };
|
||||
r.abort();
|
||||
var abortThrew = false;
|
||||
try {
|
||||
r.abort();
|
||||
} catch(e) {
|
||||
abortThrew = true;
|
||||
}
|
||||
is(abortThrew, true, "abort() must throw if not loading");
|
||||
is(abortHasRun, false, "abort() is a no-op unless loading");
|
||||
r.readAsText(asciiFile);
|
||||
r.abort();
|
||||
@ -277,7 +283,13 @@ r.onabort = function (event) {
|
||||
is(event.target.result, null, "file data should be null on aborted reads");
|
||||
}
|
||||
r.onload = function() { ok(false, "load should not fire for aborted reads") };
|
||||
r.abort();
|
||||
var abortThrew = false;
|
||||
try {
|
||||
r.abort();
|
||||
} catch(e) {
|
||||
abortThrew = true;
|
||||
}
|
||||
is(abortThrew, true, "abort() must throw if not loading");
|
||||
is(reuseAbortHasRun, false, "abort() is a no-op unless loading");
|
||||
r.readAsText(asciiFile);
|
||||
r.readAsText(asciiFile);
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "nsIVariant.h"
|
||||
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
@ -172,13 +172,14 @@ static PRInt64 GetCanvasMemoryUsed(void *) {
|
||||
return gCanvasMemoryUsed;
|
||||
}
|
||||
|
||||
// This isn't "heap-used/content/canvas/2d-pixel-bytes" because the pixels of a
|
||||
// canvas may not be stored on the heap. And if they are, they will be tracked
|
||||
// by the underlying surface implementations. See bug 655638 for details.
|
||||
// This is MR_OTHER because it's not always clear where in memory the pixels of
|
||||
// a canvas are stored. Furthermore, this memory will be tracked by the
|
||||
// underlying surface implementations. See bug 655638 for details.
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(CanvasMemory,
|
||||
"canvas-2d-pixel-bytes",
|
||||
"Memory used by 2D canvases. Each canvas "
|
||||
"requires (width * height * 4) bytes.",
|
||||
MR_OTHER,
|
||||
"Memory used by 2D canvases. Each canvas requires (width * height * 4) "
|
||||
"bytes.",
|
||||
GetCanvasMemoryUsed,
|
||||
NULL)
|
||||
|
||||
|
@ -75,7 +75,7 @@ static const char* const sEventNames[] = {
|
||||
"DOMAttrModified", "DOMCharacterDataModified",
|
||||
"DOMActivate", "DOMFocusIn", "DOMFocusOut",
|
||||
"pageshow", "pagehide", "DOMMouseScroll", "MozMousePixelScroll",
|
||||
"offline", "online", "copy", "cut", "paste",
|
||||
"offline", "online", "copy", "cut", "paste", "open", "message",
|
||||
#ifdef MOZ_SVG
|
||||
"SVGLoad", "SVGUnload", "SVGAbort", "SVGError", "SVGResize", "SVGScroll",
|
||||
"SVGZoom",
|
||||
@ -1261,6 +1261,10 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
return sEventNames[eDOMEvents_cut];
|
||||
case NS_PASTE:
|
||||
return sEventNames[eDOMEvents_paste];
|
||||
case NS_OPEN:
|
||||
return sEventNames[eDOMEvents_open];
|
||||
case NS_MESSAGE:
|
||||
return sEventNames[eDOMEvents_message];
|
||||
#ifdef MOZ_SVG
|
||||
case NS_SVG_LOAD:
|
||||
return sEventNames[eDOMEvents_SVGLoad];
|
||||
|
@ -136,6 +136,8 @@ public:
|
||||
eDOMEvents_copy,
|
||||
eDOMEvents_cut,
|
||||
eDOMEvents_paste,
|
||||
eDOMEvents_open,
|
||||
eDOMEvents_message,
|
||||
#ifdef MOZ_SVG
|
||||
eDOMEvents_SVGLoad,
|
||||
eDOMEvents_SVGUnload,
|
||||
|
@ -38,17 +38,29 @@
|
||||
|
||||
#include "nsDOMMessageEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
|
||||
if (tmp->mDataRooted) {
|
||||
tmp->UnrootData();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMMessageEvent)
|
||||
if (JSVAL_IS_GCTHING(tmp->mData)) {
|
||||
void *gcThing = JSVAL_TO_GCTHING(tmp->mData);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mData")
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
DOMCI_DATA(MessageEvent, nsDOMMessageEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent)
|
||||
@ -59,10 +71,41 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent, nsDOMEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMessageEvent::GetData(nsAString& aData)
|
||||
nsDOMMessageEvent::nsDOMMessageEvent(nsPresContext* aPresContext,
|
||||
nsEvent* aEvent)
|
||||
: nsDOMEvent(aPresContext, aEvent),
|
||||
mData(JSVAL_VOID),
|
||||
mDataRooted(false)
|
||||
{
|
||||
aData = mData;
|
||||
}
|
||||
|
||||
nsDOMMessageEvent::~nsDOMMessageEvent()
|
||||
{
|
||||
if (mDataRooted)
|
||||
UnrootData();
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMMessageEvent::RootData()
|
||||
{
|
||||
NS_ASSERTION(!mDataRooted, "...");
|
||||
NS_HOLD_JS_OBJECTS(this, nsDOMMessageEvent);
|
||||
mDataRooted = true;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMMessageEvent::UnrootData()
|
||||
{
|
||||
NS_ASSERTION(mDataRooted, "...");
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMMessageEvent);
|
||||
mDataRooted = false;
|
||||
mData = JSVAL_VOID;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMessageEvent::GetData(jsval* aData)
|
||||
{
|
||||
*aData = mData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -91,7 +134,7 @@ NS_IMETHODIMP
|
||||
nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
|
||||
PRBool aCanBubble,
|
||||
PRBool aCancelable,
|
||||
const nsAString& aData,
|
||||
const jsval& aData,
|
||||
const nsAString& aOrigin,
|
||||
const nsAString& aLastEventId,
|
||||
nsIDOMWindow* aSource)
|
||||
@ -99,7 +142,12 @@ nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
|
||||
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Allowing double-initialization seems a little silly, but we have a test
|
||||
// for it so it might be important ...
|
||||
if (mDataRooted)
|
||||
UnrootData();
|
||||
mData = aData;
|
||||
RootData();
|
||||
mOrigin = aOrigin;
|
||||
mLastEventId = aLastEventId;
|
||||
mSource = aSource;
|
||||
@ -113,8 +161,6 @@ NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
nsEvent* aEvent)
|
||||
{
|
||||
nsDOMMessageEvent* it = new nsDOMMessageEvent(aPresContext, aEvent);
|
||||
if (nsnull == it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return CallQueryInterface(it, aInstancePtrResult);
|
||||
}
|
||||
|
@ -54,21 +54,23 @@ class nsDOMMessageEvent : public nsDOMEvent,
|
||||
public nsIDOMMessageEvent
|
||||
{
|
||||
public:
|
||||
nsDOMMessageEvent(nsPresContext* aPresContext, nsEvent* aEvent)
|
||||
: nsDOMEvent(aPresContext, aEvent)
|
||||
{
|
||||
}
|
||||
nsDOMMessageEvent(nsPresContext* aPresContext, nsEvent* aEvent);
|
||||
~nsDOMMessageEvent();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMMessageEvent, nsDOMEvent)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMMessageEvent,
|
||||
nsDOMEvent)
|
||||
|
||||
NS_DECL_NSIDOMMESSAGEEVENT
|
||||
|
||||
// Forward to base class
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
|
||||
void RootData();
|
||||
void UnrootData();
|
||||
private:
|
||||
nsString mData;
|
||||
jsval mData;
|
||||
bool mDataRooted;
|
||||
nsString mOrigin;
|
||||
nsString mLastEventId;
|
||||
nsCOMPtr<nsIDOMWindow> mSource;
|
||||
|
@ -908,7 +908,7 @@ nsEventListenerManager::RegisterScriptEventListener(nsIScriptContext *aContext,
|
||||
if (sAddListenerID == JSID_VOID) {
|
||||
JSAutoRequest ar(cx);
|
||||
sAddListenerID =
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "addEventListener"));
|
||||
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "addEventListener"));
|
||||
}
|
||||
|
||||
if (aContext->GetScriptTypeID() == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
|
@ -113,7 +113,6 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMMouseScrollEvent.h"
|
||||
#include "nsIDOMDragEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
@ -390,7 +389,8 @@ public:
|
||||
static PRUint32 GetTimeoutTime();
|
||||
static PRInt32 AccelerateWheelDelta(PRInt32 aScrollLines,
|
||||
PRBool aIsHorizontal, PRBool aAllowScrollSpeedOverride,
|
||||
nsIScrollableFrame::ScrollUnit *aScrollQuantity);
|
||||
nsIScrollableFrame::ScrollUnit *aScrollQuantity,
|
||||
PRBool aLimitToMaxOnePageScroll = PR_TRUE);
|
||||
static PRBool IsAccelerationEnabled();
|
||||
|
||||
enum {
|
||||
@ -518,8 +518,18 @@ nsMouseWheelTransaction::OnEvent(nsEvent* aEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aEvent->message) {
|
||||
PRInt32 message = aEvent->message;
|
||||
// If the event is query scroll target info event, that causes modifying
|
||||
// wheel transaction because DoScrollText() needs to use them. Therefore,
|
||||
// we should handle the event as its mouse scroll event here.
|
||||
if (message == NS_QUERY_SCROLL_TARGET_INFO) {
|
||||
nsQueryContentEvent* queryEvent = static_cast<nsQueryContentEvent*>(aEvent);
|
||||
message = queryEvent->mInput.mMouseScrollEvent->message;
|
||||
}
|
||||
|
||||
switch (message) {
|
||||
case NS_MOUSE_SCROLL:
|
||||
case NS_MOUSE_PIXEL_SCROLL:
|
||||
if (sMouseMoved != 0 &&
|
||||
OutOfTime(sMouseMoved, GetIgnoreMoveDelayTime())) {
|
||||
// Terminate the current mousewheel transaction if the mouse moved more
|
||||
@ -662,7 +672,8 @@ PRInt32
|
||||
nsMouseWheelTransaction::AccelerateWheelDelta(PRInt32 aScrollLines,
|
||||
PRBool aIsHorizontal,
|
||||
PRBool aAllowScrollSpeedOverride,
|
||||
nsIScrollableFrame::ScrollUnit *aScrollQuantity)
|
||||
nsIScrollableFrame::ScrollUnit *aScrollQuantity,
|
||||
PRBool aLimitToMaxOnePageScroll)
|
||||
{
|
||||
if (aAllowScrollSpeedOverride) {
|
||||
aScrollLines = OverrideSystemScrollSpeed(aScrollLines, aIsHorizontal);
|
||||
@ -679,7 +690,8 @@ nsMouseWheelTransaction::AccelerateWheelDelta(PRInt32 aScrollLines,
|
||||
|
||||
// If the computed delta is larger than the page, we should limit
|
||||
// the delta value to the one page size.
|
||||
return LimitToOnePageScroll(aScrollLines, aIsHorizontal, aScrollQuantity);
|
||||
return !aLimitToMaxOnePageScroll ? aScrollLines :
|
||||
LimitToOnePageScroll(aScrollLines, aIsHorizontal, aScrollQuantity);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
@ -2703,6 +2715,27 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
|
||||
}
|
||||
|
||||
if (!passToParent && frameToScroll) {
|
||||
if (aScrollQuantity == nsIScrollableFrame::LINES) {
|
||||
// When this is called for querying the scroll target information,
|
||||
// we shouldn't limit the scrolling amount to less one page.
|
||||
// Otherwise, we shouldn't scroll more one page at once.
|
||||
numLines =
|
||||
nsMouseWheelTransaction::AccelerateWheelDelta(numLines, isHorizontal,
|
||||
aAllowScrollSpeedOverride,
|
||||
&aScrollQuantity,
|
||||
!aQueryEvent);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
NS_ASSERTION(!aAllowScrollSpeedOverride,
|
||||
"aAllowScrollSpeedOverride is true but the quantity isn't by-line scrolling.");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aScrollQuantity == nsIScrollableFrame::PAGES) {
|
||||
numLines = (numLines > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
if (aQueryEvent) {
|
||||
// If acceleration is enabled, pixel scroll shouldn't be used for
|
||||
// high resolution scrolling.
|
||||
@ -2718,29 +2751,18 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
|
||||
frameToScroll->GetPageScrollAmount().height / appUnitsPerDevPixel;
|
||||
aQueryEvent->mReply.mPageWidth =
|
||||
frameToScroll->GetPageScrollAmount().width / appUnitsPerDevPixel;
|
||||
|
||||
// Returns computed numLines to widget which is needed to compute the
|
||||
// pixel scrolling amout for high resolution scrolling.
|
||||
aQueryEvent->mReply.mComputedScrollAmount = numLines;
|
||||
|
||||
aQueryEvent->mSucceeded = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aScrollQuantity == nsIScrollableFrame::LINES) {
|
||||
numLines =
|
||||
nsMouseWheelTransaction::AccelerateWheelDelta(numLines, isHorizontal,
|
||||
aAllowScrollSpeedOverride,
|
||||
&aScrollQuantity);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
NS_ASSERTION(!aAllowScrollSpeedOverride,
|
||||
"aAllowScrollSpeedOverride is true but the quantity isn't by-line scrolling.");
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32 scrollX = 0;
|
||||
PRInt32 scrollY = numLines;
|
||||
|
||||
if (aScrollQuantity == nsIScrollableFrame::PAGES)
|
||||
scrollY = (scrollY > 0) ? 1 : -1;
|
||||
|
||||
if (isHorizontal) {
|
||||
scrollX = scrollY;
|
||||
scrollY = 0;
|
||||
@ -2757,6 +2779,8 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
|
||||
mode = nsIScrollableFrame::NORMAL;
|
||||
}
|
||||
|
||||
// XXX Why don't we limit the pixel scroll amount to less one page??
|
||||
|
||||
nsIntPoint overflow;
|
||||
frameToScroll->ScrollBy(nsIntPoint(scrollX, scrollY), aScrollQuantity,
|
||||
mode, &overflow);
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
|
@ -64,7 +64,6 @@
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMProgressEvent.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -68,7 +68,6 @@
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsMediaError.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
@ -2250,12 +2249,12 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer,
|
||||
// which frees the memory when it's destroyed.
|
||||
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(GetOwnerDoc()));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetOwnerDoc());
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(static_cast<nsIContent*>(this)));
|
||||
NS_ENSURE_TRUE(docEvent && target, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(domDoc && target, NS_ERROR_INVALID_ARG);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
nsresult rv = docEvent->CreateEvent(NS_LITERAL_STRING("MozAudioAvailableEvent"),
|
||||
nsresult rv = domDoc->CreateEvent(NS_LITERAL_STRING("MozAudioAvailableEvent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMNotifyAudioAvailableEvent> audioavailableEvent(do_QueryInterface(event));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -57,7 +57,6 @@
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
|
||||
// Notify/query select frame for selectedIndex
|
||||
#include "nsIDocument.h"
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMProgressEvent.h"
|
||||
#include "nsMediaError.h"
|
||||
|
||||
|
@ -276,6 +276,7 @@ _TEST_FILES = \
|
||||
test_bug514437.html \
|
||||
test_bug560112.html \
|
||||
test_bug649134.html \
|
||||
test_bug658746.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
98
content/html/content/test/test_bug658746.html
Normal file
98
content/html/content/test/test_bug658746.html
Normal file
@ -0,0 +1,98 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=658746
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 658746</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<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=658746">Mozilla Bug 658746</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 658746 **/
|
||||
|
||||
/**
|
||||
* Sets property, gets property and deletes property.
|
||||
*/
|
||||
function SetGetDelete(prop)
|
||||
{
|
||||
var el = document.createElement('div');
|
||||
|
||||
el.dataset[prop] = 'aaaaaa';
|
||||
is(el.dataset[prop], 'aaaaaa', 'Dataset property "' + prop + '" should have been set.');
|
||||
|
||||
delete el.dataset[prop];
|
||||
is(el.dataset[prop], undefined, 'Dataset property"' + prop + '" should have been deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets, deletes and sets property. Expects exception while trying to set property.
|
||||
*/
|
||||
function SetExpectException(prop)
|
||||
{
|
||||
var el = document.createElement('div');
|
||||
|
||||
is(el.dataset[prop], undefined, 'Dataset property "' + prop + '" should be undefined.');
|
||||
delete el.dataset[prop];
|
||||
|
||||
try {
|
||||
el.dataset[prop] = "xxxxxx";
|
||||
ok(false, 'Exception should have been thrown when setting "' + prop + '".');
|
||||
} catch (ex) {
|
||||
ok(true, 'Exception should have been thrown.');
|
||||
}
|
||||
}
|
||||
|
||||
// Numbers as properties.
|
||||
SetGetDelete(-12345678901234567980);
|
||||
SetGetDelete(-1);
|
||||
SetGetDelete(0);
|
||||
SetGetDelete(1);
|
||||
SetGetDelete(12345678901234567980);
|
||||
|
||||
// Floating point numbers as properties.
|
||||
SetGetDelete(-1.1);
|
||||
SetGetDelete(0.0);
|
||||
SetGetDelete(1.1);
|
||||
|
||||
// Hexadecimal numbers as properties.
|
||||
SetGetDelete(0x3);
|
||||
SetGetDelete(0xa);
|
||||
|
||||
// Octal numbers as properties.
|
||||
SetGetDelete(03);
|
||||
SetGetDelete(07);
|
||||
|
||||
// String numbers as properties.
|
||||
SetGetDelete('0');
|
||||
SetGetDelete('01');
|
||||
SetGetDelete('0x1');
|
||||
|
||||
// Undefined as property.
|
||||
SetGetDelete(undefined);
|
||||
|
||||
// Empty arrays as properties.
|
||||
SetGetDelete(new Array());
|
||||
SetGetDelete([]);
|
||||
|
||||
// Non-empty array and object as properties.
|
||||
SetExpectException(['a', 'b']);
|
||||
SetExpectException({'a':'b'});
|
||||
|
||||
// Objects as properties.
|
||||
SetExpectException(new Object());
|
||||
SetExpectException(document);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -3322,7 +3322,7 @@ nsHTMLDocument::DoClipboardSecurityCheck(PRBool aPaste)
|
||||
if (aPaste) {
|
||||
if (nsHTMLDocument::sPasteInternal_id == JSID_VOID) {
|
||||
nsHTMLDocument::sPasteInternal_id =
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "paste"));
|
||||
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "paste"));
|
||||
}
|
||||
rv = secMan->CheckPropertyAccess(cx, nsnull, classNameStr.get(),
|
||||
nsHTMLDocument::sPasteInternal_id,
|
||||
@ -3330,7 +3330,7 @@ nsHTMLDocument::DoClipboardSecurityCheck(PRBool aPaste)
|
||||
} else {
|
||||
if (nsHTMLDocument::sCutCopyInternal_id == JSID_VOID) {
|
||||
nsHTMLDocument::sCutCopyInternal_id =
|
||||
INTERNED_STRING_TO_JSID(::JS_InternString(cx, "cutcopy"));
|
||||
INTERNED_STRING_TO_JSID(cx, ::JS_InternString(cx, "cutcopy"));
|
||||
}
|
||||
rv = secMan->CheckPropertyAccess(cx, nsnull, classNameStr.get(),
|
||||
nsHTMLDocument::sCutCopyInternal_id,
|
||||
|
@ -72,7 +72,7 @@ nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
|
||||
{
|
||||
NS_ASSERTION(mDecoder->OnStateMachineThread(),
|
||||
"Should be on state machine thread.");
|
||||
mozilla::MonitorAutoEnter autoEnter(mMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
|
||||
|
||||
nsMediaStream* stream = mDecoder->GetCurrentStream();
|
||||
NS_ASSERTION(stream, "Decoder has no media stream");
|
||||
@ -126,8 +126,8 @@ nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
|
||||
|
||||
PRInt64 length = stream->GetLength();
|
||||
if (length != -1) {
|
||||
mozilla::MonitorAutoExit autoExitMonitor(mMonitor);
|
||||
mozilla::MonitorAutoEnter autoMonitor(mDecoder->GetMonitor());
|
||||
mozilla::ReentrantMonitorAutoExit autoExitMonitor(mReentrantMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->GetStateMachine()->SetDuration(USECS_PER_S *
|
||||
(length - sizeof(nsRawVideoHeader)) /
|
||||
(mFrameSize * mFrameRate));
|
||||
@ -171,7 +171,7 @@ PRBool nsRawReader::ReadFromStream(nsMediaStream *aStream, PRUint8* aBuf,
|
||||
PRBool nsRawReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
|
||||
PRInt64 aTimeThreshold)
|
||||
{
|
||||
mozilla::MonitorAutoEnter autoEnter(mMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
|
||||
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
|
||||
"Should be on state machine thread or decode thread.");
|
||||
|
||||
@ -253,7 +253,7 @@ PRBool nsRawReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
|
||||
|
||||
nsresult nsRawReader::Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
|
||||
{
|
||||
mozilla::MonitorAutoEnter autoEnter(mMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
|
||||
NS_ASSERTION(mDecoder->OnStateMachineThread(),
|
||||
"Should be on state machine thread.");
|
||||
|
||||
@ -284,8 +284,8 @@ nsresult nsRawReader::Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime,
|
||||
}
|
||||
|
||||
{
|
||||
mozilla::MonitorAutoExit autoMonitorExit(mMonitor);
|
||||
mozilla::MonitorAutoEnter autoMonitor(mDecoder->GetMonitor());
|
||||
mozilla::ReentrantMonitorAutoExit autoMonitorExit(mReentrantMonitor);
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mDecoder->GetReentrantMonitor());
|
||||
if (mDecoder->GetDecodeState() ==
|
||||
nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
|
||||
mCurrentFrame = frame;
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGSVGElement.h"
|
||||
#include "nsSVGEffects.h" // For nsSVGEffects::RemoveAllRenderingObservers
|
||||
#include "nsContentErrors.h" // For NS_PROPTABLE_PROP_OVERWRITTEN
|
||||
|
||||
#ifdef MOZ_SMIL
|
||||
@ -1289,15 +1288,6 @@ nsSVGSVGElement::GetPreserveAspectRatio()
|
||||
return &mPreserveAspectRatio;
|
||||
}
|
||||
|
||||
#ifndef MOZ_ENABLE_LIBXUL
|
||||
// XXXdholbert HACK -- see comment w/ this method's declaration in header file.
|
||||
void
|
||||
nsSVGSVGElement::RemoveAllRenderingObservers()
|
||||
{
|
||||
nsSVGEffects::RemoveAllRenderingObservers(this);
|
||||
}
|
||||
#endif // !MOZ_LIBXUL
|
||||
|
||||
PRBool
|
||||
nsSVGSVGElement::ShouldSynthesizeViewBox()
|
||||
{
|
||||
|
@ -226,13 +226,6 @@ public:
|
||||
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
||||
#ifndef MOZ_ENABLE_LIBXUL
|
||||
// XXXdholbert HACK to call static method
|
||||
// nsSVGEffects::RemoveAllRenderingObservers() on myself, on behalf
|
||||
// of imagelib in non-libxul builds.
|
||||
virtual void RemoveAllRenderingObservers();
|
||||
#endif // !MOZ_LIBXUL
|
||||
|
||||
private:
|
||||
// Methods for <image> elements to override my "PreserveAspectRatio" value.
|
||||
// These are private so that only our friends (nsSVGImageFrame in
|
||||
|
@ -64,9 +64,8 @@ nsSVGDocument::~nsSVGDocument()
|
||||
DOMCI_NODE_DATA(SVGDocument, nsSVGDocument)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsSVGDocument)
|
||||
NS_INTERFACE_TABLE_INHERITED2(nsSVGDocument,
|
||||
nsIDOMSVGDocument,
|
||||
nsIDOMDocumentEvent)
|
||||
NS_INTERFACE_TABLE_INHERITED1(nsSVGDocument,
|
||||
nsIDOMSVGDocument)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDocument)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument)
|
||||
|
@ -54,7 +54,6 @@ public:
|
||||
NS_DECL_NSIDOMSVGDOCUMENT
|
||||
NS_FORWARD_NSIDOMDOCUMENT(nsXMLDocument::)
|
||||
NS_FORWARD_NSIDOMNODE(nsXMLDocument::)
|
||||
NS_FORWARD_NSIDOMDOCUMENTEVENT(nsXMLDocument::)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
virtual nsXPCClassInfo* GetClassInfo();
|
||||
|
@ -43,10 +43,7 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
DIRS = external
|
||||
endif
|
||||
|
||||
MODULE = morkreader
|
||||
LIBRARY_NAME = morkreader_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
@ -155,6 +155,7 @@ EXPORTS
|
||||
sqlite3_sql
|
||||
sqlite3_status
|
||||
sqlite3_step
|
||||
sqlite3_stmt_readonly
|
||||
sqlite3_stmt_status
|
||||
sqlite3_thread_cleanup
|
||||
sqlite3_total_changes
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user