mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
merge fx-team to mozilla-central
This commit is contained in:
commit
8f6047c9d2
@ -415,7 +415,7 @@ skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s
|
||||
[browser_visibleTabs_contextMenu.js]
|
||||
skip-if = e10s # Bug 921905 - pinTab/unpinTab fail in e10s
|
||||
[browser_visibleTabs_tabPreview.js]
|
||||
skip-if = e10s # Bug ????? - thumbnail captures need e10s love (tabPreviews_capture fails with Argument 1 of CanvasRenderingContext2D.drawWindow does not implement interface Window.)
|
||||
skip-if = (os == "win" && !debug) || e10s # Bug 1007418 / Bug 698371 - thumbnail captures need e10s love (tabPreviews_capture fails with Argument 1 of CanvasRenderingContext2D.drawWindow does not implement interface Window.)
|
||||
[browser_windowopen_reflows.js]
|
||||
[browser_wyciwyg_urlbarCopying.js]
|
||||
skip-if = e10s # Bug ?????? - test directly manipulates content (content.document.getElementById)
|
||||
|
@ -773,6 +773,7 @@ bin/libfreebl_32int64_3.so
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@BINPATH@/components/CrashService.manifest
|
||||
@BINPATH@/components/CrashService.js
|
||||
@BINPATH@/components/toolkit_crashservice.xpt
|
||||
#ifdef XP_MACOSX
|
||||
@BINPATH@/crashreporter.app/
|
||||
#else
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
#include "nsICrashService.h"
|
||||
#endif
|
||||
|
||||
using namespace base;
|
||||
@ -133,8 +134,37 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
|
||||
ret = CrashReporter::AppendExtraData(mChildDumpID, *processNotes);
|
||||
if (!ret)
|
||||
NS_WARNING("problem appending child data to .extra");
|
||||
|
||||
NotifyCrashService();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
CrashReporterParent::NotifyCrashService()
|
||||
{
|
||||
nsCOMPtr<nsICrashService> crashService =
|
||||
do_GetService("@mozilla.org/crashservice;1");
|
||||
if (!crashService) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mProcessType == GeckoProcessType_Content) {
|
||||
crashService->AddCrash(nsICrashService::PROCESS_TYPE_CONTENT,
|
||||
nsICrashService::CRASH_TYPE_CRASH,
|
||||
mChildDumpID);
|
||||
}
|
||||
else if (mProcessType == GeckoProcessType_Plugin) {
|
||||
nsAutoCString val;
|
||||
int32_t crashType = nsICrashService::CRASH_TYPE_CRASH;
|
||||
if (mNotes.Get(NS_LITERAL_CSTRING("PluginHang"), &val) &&
|
||||
val.Equals(NS_LITERAL_CSTRING("1"))) {
|
||||
crashType = nsICrashService::CRASH_TYPE_HANG;
|
||||
}
|
||||
crashService->AddCrash(nsICrashService::PROCESS_TYPE_PLUGIN, crashType,
|
||||
mChildDumpID);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace dom
|
||||
|
@ -90,6 +90,11 @@ public:
|
||||
CloneProtocol(Channel* aChannel,
|
||||
mozilla::ipc::ProtocolCloneContext *aCtx) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
void
|
||||
NotifyCrashService();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
AnnotationTable mNotes;
|
||||
#endif
|
||||
|
@ -4,8 +4,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'cocoa':
|
||||
TEST_DIRS += ['tests']
|
||||
TEST_DIRS += ['tests']
|
||||
|
||||
EXPORTS += [
|
||||
'nsICachedFileDescriptorListener.h',
|
||||
|
@ -3,3 +3,6 @@ run-if = toolkit == 'gonk'
|
||||
[test_NuwaProcessDeadlock.html]
|
||||
run-if = toolkit == 'gonk'
|
||||
[test_child_docshell.html]
|
||||
run-if = toolkit != 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
|
||||
[test_CrashService_crash.html]
|
||||
run-if = crashreporter && !e10s && (toolkit == 'gtk2' || toolkit == 'gtk3' || toolkit == 'cocoa' || toolkit == 'windows') && (buildapp != 'b2g' || toolkit == 'gonk')
|
||||
|
93
dom/ipc/tests/test_CrashService_crash.html
Normal file
93
dom/ipc/tests/test_CrashService_crash.html
Normal file
@ -0,0 +1,93 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Ensures that content crashes are reported to the crash service
|
||||
(nsICrashService and CrashManager.jsm).
|
||||
-->
|
||||
<head>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.7">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.addPermission("browser", true, document);
|
||||
SpecialPowers.pushPrefEnv({'set':[
|
||||
["dom.mozBrowserFramesEnabled", true],
|
||||
["dom.ipc.tabs.disabled", false]
|
||||
]}, function () {
|
||||
|
||||
var iframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe');
|
||||
iframe.setAttribute("remote", "true");
|
||||
SpecialPowers.wrap(iframe).mozbrowser = true;
|
||||
document.documentElement.appendChild(iframe);
|
||||
|
||||
SimpleTest.expectChildProcessCrash();
|
||||
|
||||
var crashMan =
|
||||
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").
|
||||
Services.crashmanager;
|
||||
|
||||
// First, clear the crash record store.
|
||||
info("Waiting for pruneOldCrashes");
|
||||
var future = new Date(Date.now() + 1000 * 60 * 60 * 24);
|
||||
crashMan.pruneOldCrashes(future).then(function () {
|
||||
|
||||
var crashDateMS = Date.now();
|
||||
|
||||
// Inject a frame script that crashes the content process.
|
||||
var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.loadFrameScript('data:,new ' + function ContentScriptScope() {
|
||||
let Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
let crash = function() {
|
||||
let zero = new ctypes.intptr_t(8);
|
||||
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
|
||||
badptr.contents;
|
||||
};
|
||||
privateNoteIntentionalCrash();
|
||||
crash();
|
||||
}, false);
|
||||
|
||||
// Finally, poll for the new crash record.
|
||||
function tryGetCrash() {
|
||||
info("Waiting for getCrashes");
|
||||
crashMan.getCrashes().then(function (crashes) {
|
||||
if (crashes.length) {
|
||||
is(crashes.length, 1, "There should be only one record");
|
||||
var crash = SpecialPowers.wrap(crashes[0]);
|
||||
ok(crash.isOfType(crashMan.PROCESS_TYPE_CONTENT,
|
||||
crashMan.CRASH_TYPE_CRASH),
|
||||
"Record should be a content crash");
|
||||
ok(!!crash.id, "Record should have an ID");
|
||||
ok(!!crash.crashDate, "Record should have a crash date");
|
||||
var dateMS = crash.crashDate.valueOf();
|
||||
var twoMin = 1000 * 60 * 2;
|
||||
ok(crashDateMS - twoMin <= dateMS &&
|
||||
dateMS <= crashDateMS + twoMin,
|
||||
"Record's crash date should be nowish: " +
|
||||
"now=" + crashDateMS + " recordDate=" + dateMS);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
else {
|
||||
setTimeout(tryGetCrash, 1000);
|
||||
}
|
||||
}, function (err) {
|
||||
ok(false, "Error getting crashes: " + err);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
setTimeout(tryGetCrash, 1000);
|
||||
|
||||
}, function () {
|
||||
ok(false, "pruneOldCrashes error");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -55,6 +55,10 @@ skip-if = (toolkit != "gtk2") && (toolkit != "gtk3")
|
||||
skip-if = !crashreporter
|
||||
[test_crashing2.html]
|
||||
skip-if = (!crashreporter) || true # Bug 566049
|
||||
[test_CrashService_crash.html]
|
||||
skip-if = !crashreporter || e10s
|
||||
[test_CrashService_hang.html]
|
||||
skip-if = !crashreporter || e10s
|
||||
[test_defaultValue.html]
|
||||
[test_enumerate.html]
|
||||
[test_fullpage.html]
|
||||
|
28
dom/plugins/test/mochitest/test_CrashService_crash.html
Normal file
28
dom/plugins/test/mochitest/test_CrashService_crash.html
Normal file
@ -0,0 +1,28 @@
|
||||
<head>
|
||||
<title>nsICrashService plugin crash</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="utils.js"></script>
|
||||
|
||||
<body>
|
||||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
|
||||
window.frameLoaded = function frameLoaded_toCrash() {
|
||||
if (!SimpleTest.testPluginIsOOP()) {
|
||||
ok(true, "Skipping this test when test plugin is not OOP.");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleTest.expectChildProcessCrash();
|
||||
|
||||
crashAndGetCrashServiceRecord("crash", function (cm, crash) {
|
||||
ok(crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_CRASH),
|
||||
"Record should be a plugin crash");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
|
31
dom/plugins/test/mochitest/test_CrashService_hang.html
Normal file
31
dom/plugins/test/mochitest/test_CrashService_hang.html
Normal file
@ -0,0 +1,31 @@
|
||||
<head>
|
||||
<title>nsICrashService plugin hang</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="utils.js"></script>
|
||||
|
||||
<body>
|
||||
<script class="testbody" type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
||||
|
||||
window.frameLoaded = function frameLoaded_toCrash() {
|
||||
if (!SimpleTest.testPluginIsOOP()) {
|
||||
ok(true, "Skipping this test when test plugin is not OOP.");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleTest.expectChildProcessCrash();
|
||||
|
||||
// the default timeout is annoying high for mochitest runs
|
||||
var timeoutPref = "dom.ipc.plugins.timeoutSecs";
|
||||
SpecialPowers.setIntPref(timeoutPref, 5);
|
||||
|
||||
crashAndGetCrashServiceRecord("hang", function (cm, crash) {
|
||||
ok(crash.isOfType(cm.PROCESS_TYPE_PLUGIN, cm.CRASH_TYPE_HANG),
|
||||
"Record should be a plugin hang");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<iframe id="iframe1" src="crashing_subpage.html" width="600" height="600"></iframe>
|
@ -42,3 +42,59 @@ function setTestPluginEnabledState(newEnabledState, pluginName) {
|
||||
getTestPlugin(pluginName).enabledState = oldEnabledState;
|
||||
});
|
||||
}
|
||||
|
||||
function crashAndGetCrashServiceRecord(crashMethodName, callback) {
|
||||
var crashMan =
|
||||
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").
|
||||
Services.crashmanager;
|
||||
|
||||
// First, clear the crash record store.
|
||||
info("Waiting for pruneOldCrashes");
|
||||
var future = new Date(Date.now() + 1000 * 60 * 60 * 24);
|
||||
crashMan.pruneOldCrashes(future).then(function () {
|
||||
|
||||
var iframe = document.getElementById("iframe1");
|
||||
var p = iframe.contentDocument.getElementById("plugin1");
|
||||
|
||||
var crashDateMS = Date.now();
|
||||
try {
|
||||
p[crashMethodName]();
|
||||
ok(false, "p." + crashMethodName + "() should throw an exception");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "p." + crashMethodName + "() should throw an exception");
|
||||
}
|
||||
|
||||
// The crash record store is written and read back asyncly, so poll for
|
||||
// the new record.
|
||||
function tryGetCrash() {
|
||||
info("Waiting for getCrashes");
|
||||
crashMan.getCrashes().then(function (crashes) {
|
||||
if (crashes.length) {
|
||||
is(crashes.length, 1, "There should be only one record");
|
||||
var crash = SpecialPowers.wrap(crashes[0]);
|
||||
ok(!!crash.id, "Record should have an ID");
|
||||
ok(!!crash.crashDate, "Record should have a crash date");
|
||||
var dateMS = crash.crashDate.valueOf();
|
||||
var twoMin = 1000 * 60 * 2;
|
||||
ok(crashDateMS - twoMin <= dateMS &&
|
||||
dateMS <= crashDateMS + twoMin,
|
||||
"Record's crash date should be nowish: " +
|
||||
"now=" + crashDateMS + " recordDate=" + dateMS);
|
||||
callback(crashMan, crash);
|
||||
}
|
||||
else {
|
||||
setTimeout(tryGetCrash, 1000);
|
||||
}
|
||||
}, function (err) {
|
||||
ok(false, "Error getting crashes: " + err);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
setTimeout(tryGetCrash, 1000);
|
||||
|
||||
}, function () {
|
||||
ok(false, "pruneOldCrashes error");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
|
||||
import org.mozilla.gecko.GeckoProfileDirectories.NoSuchProfileException;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.util.INIParser;
|
||||
import org.mozilla.gecko.util.INISection;
|
||||
|
||||
@ -577,6 +579,11 @@ public final class GeckoProfile {
|
||||
// only set as default if this is the first non-webapp
|
||||
// profile we're creating
|
||||
profileSection.setProperty("Default", 1);
|
||||
|
||||
// We have no intention of stopping this session. The FIRSTRUN session
|
||||
// ends when the browsing session/activity has ended. All events
|
||||
// during firstrun will be tagged as FIRSTRUN.
|
||||
Telemetry.startUISession(TelemetryContract.Session.FIRSTRUN);
|
||||
}
|
||||
|
||||
parser.addSection(profileSection);
|
||||
|
@ -252,7 +252,11 @@ cd $(2) && zip -q $(1) -r * -x $(not_android_res_files)
|
||||
|
||||
endef
|
||||
|
||||
# We delete the archive before updating so that resources removed from
|
||||
# the filesystem are removed from the archive.
|
||||
geckoview_resources.zip: $(all_resources) $(GLOBAL_DEPS)
|
||||
$(REPORT_BUILD)
|
||||
$(RM) -rf $@
|
||||
$(foreach dir,$(ANDROID_RES_DIRS),$(call zip_directory_with_relative_paths,$(CURDIR)/$@,$(dir)))
|
||||
|
||||
# All of generated/org/mozilla/gecko/R.java, gecko.ap_, and R.txt are
|
||||
|
@ -113,6 +113,9 @@ public interface TelemetryContract {
|
||||
|
||||
// Awesomescreen frecency search is active.
|
||||
public static final String FRECENCY = "frecency.1";
|
||||
|
||||
// Started the very first time we believe the application has been launched.
|
||||
public static final String FIRSTRUN = "firstrun.1";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +119,7 @@ public class TopSitesGridView extends GridView {
|
||||
} else {
|
||||
method = TelemetryContract.Method.GRID_ITEM;
|
||||
}
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, Integer.toString(position));
|
||||
|
||||
mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ import com.jayway.android.robotium.solo.Solo;
|
||||
public class AppMenuComponent extends BaseComponent {
|
||||
public enum MenuItem {
|
||||
FORWARD(R.string.forward),
|
||||
NEW_TAB(R.string.new_tab);
|
||||
NEW_TAB(R.string.new_tab),
|
||||
RELOAD(R.string.reload);
|
||||
|
||||
private final int resourceID;
|
||||
private String stringResource;
|
||||
|
@ -80,6 +80,10 @@ public class ToolbarComponent extends BaseComponent {
|
||||
return (ImageButton) getToolbarView().findViewById(R.id.forward);
|
||||
}
|
||||
|
||||
private ImageButton getReloadButton() {
|
||||
DeviceHelper.assertIsTablet();
|
||||
return (ImageButton) getToolbarView().findViewById(R.id.reload);
|
||||
}
|
||||
/**
|
||||
* Returns the View for the edit cancel button in the browser toolbar.
|
||||
*/
|
||||
@ -190,6 +194,11 @@ public class ToolbarComponent extends BaseComponent {
|
||||
return pressButton(forwardButton, "forward");
|
||||
}
|
||||
|
||||
public ToolbarComponent pressReloadButton() {
|
||||
final ImageButton reloadButton = getReloadButton();
|
||||
return pressButton(reloadButton, "reload");
|
||||
}
|
||||
|
||||
private ToolbarComponent pressButton(final View view, final String buttonName) {
|
||||
fAssertNotNull("The " + buttonName + " button View is not null", view);
|
||||
fAssertTrue("The " + buttonName + " button is enabled", view.isEnabled());
|
||||
|
@ -88,9 +88,17 @@ final public class NavigationHelper {
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
// TODO: On tablets, press reload in TOOLBAR. Note that this is technically
|
||||
// an app menu item so tread carefully.
|
||||
// On phones, press reload in APPMENU.
|
||||
throw new UnsupportedOperationException("Not yet implemented.");
|
||||
if (DeviceHelper.isTablet()) {
|
||||
sToolbar.pressReloadButton(); // Waits for page load & asserts isNotEditing.
|
||||
return;
|
||||
}
|
||||
|
||||
sToolbar.assertIsNotEditing();
|
||||
WaitHelper.waitForPageLoad(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sAppMenu.pressMenuItem(AppMenuComponent.MenuItem.RELOAD);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,7 @@ public class testSessionHistory extends UITest {
|
||||
NavigationHelper.goForward();
|
||||
mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
|
||||
|
||||
// TODO: Implement this functionality and uncomment.
|
||||
/*
|
||||
NavigationHelper.reload();
|
||||
mToolbar.assertTitle(StringHelper.ROBOCOP_BLANK_PAGE_02_TITLE);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -1004,11 +1004,17 @@ public class BrowserToolbar extends ThemedRelativeLayout
|
||||
ViewHelper.setTranslationX(urlBarTranslatingEdge, entryTranslation);
|
||||
}
|
||||
|
||||
// Prevent taps through the editing mode cancel button (bug 1001243).
|
||||
tabsButton.setEnabled(false);
|
||||
|
||||
ViewHelper.setTranslationX(tabsButton, curveTranslation);
|
||||
ViewHelper.setTranslationX(tabsCounter, curveTranslation);
|
||||
ViewHelper.setTranslationX(actionItemBar, curveTranslation);
|
||||
|
||||
if (hasSoftMenuButton) {
|
||||
// Prevent tabs through the editing mode cancel button (bug 1001243).
|
||||
menuButton.setEnabled(false);
|
||||
|
||||
ViewHelper.setTranslationX(menuButton, curveTranslation);
|
||||
ViewHelper.setTranslationX(menuIcon, curveTranslation);
|
||||
}
|
||||
@ -1130,11 +1136,15 @@ public class BrowserToolbar extends ThemedRelativeLayout
|
||||
}
|
||||
}
|
||||
|
||||
tabsButton.setEnabled(true);
|
||||
|
||||
ViewHelper.setTranslationX(tabsButton, 0);
|
||||
ViewHelper.setTranslationX(tabsCounter, 0);
|
||||
ViewHelper.setTranslationX(actionItemBar, 0);
|
||||
|
||||
if (hasSoftMenuButton) {
|
||||
menuButton.setEnabled(true);
|
||||
|
||||
ViewHelper.setTranslationX(menuButton, 0);
|
||||
ViewHelper.setTranslationX(menuIcon, 0);
|
||||
}
|
||||
|
@ -1073,6 +1073,23 @@ org.mozilla.crashes.crashes
|
||||
|
||||
This measurement contains a historical record of application crashes.
|
||||
|
||||
Version 3
|
||||
^^^^^^^^^
|
||||
|
||||
This version follows up from version 2, building on improvements to
|
||||
the :ref:`crashes_crashmanager`.
|
||||
|
||||
This measurement will be reported on each day there was a
|
||||
crash. Records may contain the following fields, whose values indicate
|
||||
the number of crashes or hangs that occurred on the given day:
|
||||
|
||||
* main-crash
|
||||
* main-hang
|
||||
* content-crash
|
||||
* content-hang
|
||||
* plugin-crash
|
||||
* plugin-hang
|
||||
|
||||
Version 2
|
||||
^^^^^^^^^
|
||||
|
||||
|
@ -1021,6 +1021,26 @@ DailyCrashesMeasurement2.prototype = Object.freeze({
|
||||
},
|
||||
});
|
||||
|
||||
function DailyCrashesMeasurement3() {
|
||||
Metrics.Measurement.call(this);
|
||||
}
|
||||
|
||||
DailyCrashesMeasurement3.prototype = Object.freeze({
|
||||
__proto__: Metrics.Measurement.prototype,
|
||||
|
||||
name: "crashes",
|
||||
version: 3,
|
||||
|
||||
fields: {
|
||||
"main-crash": DAILY_LAST_NUMERIC_FIELD,
|
||||
"main-hang": DAILY_LAST_NUMERIC_FIELD,
|
||||
"content-crash": DAILY_LAST_NUMERIC_FIELD,
|
||||
"content-hang": DAILY_LAST_NUMERIC_FIELD,
|
||||
"plugin-crash": DAILY_LAST_NUMERIC_FIELD,
|
||||
"plugin-hang": DAILY_LAST_NUMERIC_FIELD,
|
||||
},
|
||||
});
|
||||
|
||||
this.CrashesProvider = function () {
|
||||
Metrics.Provider.call(this);
|
||||
|
||||
@ -1036,6 +1056,7 @@ CrashesProvider.prototype = Object.freeze({
|
||||
measurementTypes: [
|
||||
DailyCrashesMeasurement1,
|
||||
DailyCrashesMeasurement2,
|
||||
DailyCrashesMeasurement3,
|
||||
],
|
||||
|
||||
pullOnly: true,
|
||||
@ -1047,11 +1068,9 @@ CrashesProvider.prototype = Object.freeze({
|
||||
_populateCrashCounts: function () {
|
||||
this._log.info("Grabbing crash counts from crash manager.");
|
||||
let crashCounts = yield this._manager.getCrashCountsByDay();
|
||||
let fields = {
|
||||
"main-crash": "mainCrash",
|
||||
};
|
||||
|
||||
let m = this.getMeasurement("crashes", 2);
|
||||
let m = this.getMeasurement("crashes", 3);
|
||||
let fields = DailyCrashesMeasurement3.prototype.fields;
|
||||
|
||||
for (let [day, types] of crashCounts) {
|
||||
let date = Metrics.daysToDate(day);
|
||||
@ -1061,7 +1080,7 @@ CrashesProvider.prototype = Object.freeze({
|
||||
continue;
|
||||
}
|
||||
|
||||
yield m.setDailyLastNumeric(fields[type], count, date);
|
||||
yield m.setDailyLastNumeric(type, count, date);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -47,40 +47,62 @@ add_task(function* test_collect() {
|
||||
let day1 = new Date(2014, 0, 1, 0, 0, 0);
|
||||
let day2 = new Date(2014, 0, 3, 0, 0, 0);
|
||||
|
||||
// FUTURE Bug 982836 CrashManager will grow public APIs for adding crashes.
|
||||
// Switch to that here.
|
||||
let store = yield manager._getStore();
|
||||
store.addMainProcessCrash("id1", day1);
|
||||
store.addMainProcessCrash("id2", day1);
|
||||
store.addMainProcessCrash("id3", day2);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
|
||||
manager.CRASH_TYPE_CRASH,
|
||||
"mc1", day1);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
|
||||
manager.CRASH_TYPE_CRASH,
|
||||
"mc2", day1);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_CONTENT,
|
||||
manager.CRASH_TYPE_HANG,
|
||||
"ch", day1);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_PLUGIN,
|
||||
manager.CRASH_TYPE_CRASH,
|
||||
"pc", day1);
|
||||
|
||||
// Flush changes (this may not be needed but it doesn't hurt).
|
||||
yield store.save();
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
|
||||
manager.CRASH_TYPE_HANG,
|
||||
"mh", day2);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_CONTENT,
|
||||
manager.CRASH_TYPE_CRASH,
|
||||
"cc", day2);
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_PLUGIN,
|
||||
manager.CRASH_TYPE_HANG,
|
||||
"ph", day2);
|
||||
|
||||
yield provider.collectDailyData();
|
||||
|
||||
let m = provider.getMeasurement("crashes", 2);
|
||||
let m = provider.getMeasurement("crashes", 3);
|
||||
let values = yield m.getValues();
|
||||
do_check_eq(values.days.size, 2);
|
||||
do_check_true(values.days.hasDay(day1));
|
||||
do_check_true(values.days.hasDay(day2));
|
||||
|
||||
let value = values.days.getDay(day1);
|
||||
do_check_true(value.has("mainCrash"));
|
||||
do_check_eq(value.get("mainCrash"), 2);
|
||||
do_check_true(value.has("main-crash"));
|
||||
do_check_eq(value.get("main-crash"), 2);
|
||||
do_check_true(value.has("content-hang"));
|
||||
do_check_eq(value.get("content-hang"), 1);
|
||||
do_check_true(value.has("plugin-crash"));
|
||||
do_check_eq(value.get("plugin-crash"), 1);
|
||||
|
||||
value = values.days.getDay(day2);
|
||||
do_check_eq(value.get("mainCrash"), 1);
|
||||
do_check_true(value.has("main-hang"));
|
||||
do_check_eq(value.get("main-hang"), 1);
|
||||
do_check_true(value.has("content-crash"));
|
||||
do_check_eq(value.get("content-crash"), 1);
|
||||
do_check_true(value.has("plugin-hang"));
|
||||
do_check_eq(value.get("plugin-hang"), 1);
|
||||
|
||||
// Check that adding a new crash increments counter on next collect.
|
||||
store = yield manager._getStore();
|
||||
store.addMainProcessCrash("id4", day2);
|
||||
yield store.save();
|
||||
yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
|
||||
manager.CRASH_TYPE_HANG,
|
||||
"mc3", day2);
|
||||
|
||||
yield provider.collectDailyData();
|
||||
values = yield m.getValues();
|
||||
value = values.days.getDay(day2);
|
||||
do_check_eq(value.get("mainCrash"), 2);
|
||||
do_check_eq(value.get("main-hang"), 2);
|
||||
|
||||
yield provider.shutdown();
|
||||
yield storage.close();
|
||||
|
@ -121,6 +121,21 @@ this.CrashManager = function (options) {
|
||||
};
|
||||
|
||||
this.CrashManager.prototype = Object.freeze({
|
||||
// A crash in the main process.
|
||||
PROCESS_TYPE_MAIN: "main",
|
||||
|
||||
// A crash in a content process.
|
||||
PROCESS_TYPE_CONTENT: "content",
|
||||
|
||||
// A crash in a plugin process.
|
||||
PROCESS_TYPE_PLUGIN: "plugin",
|
||||
|
||||
// A real crash.
|
||||
CRASH_TYPE_CRASH: "crash",
|
||||
|
||||
// A hang.
|
||||
CRASH_TYPE_HANG: "hang",
|
||||
|
||||
DUMP_REGEX: /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.dmp$/i,
|
||||
SUBMITTED_REGEX: /^bp-(?:hr-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.txt$/i,
|
||||
ALL_REGEX: /^(.*)$/,
|
||||
@ -323,6 +338,28 @@ this.CrashManager.prototype = Object.freeze({
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Record the occurrence of a crash.
|
||||
*
|
||||
* This method skips event files altogether and writes directly and
|
||||
* immediately to the manager's data store.
|
||||
*
|
||||
* @param processType (string) One of the PROCESS_TYPE constants.
|
||||
* @param crashType (string) One of the CRASH_TYPE constants.
|
||||
* @param id (string) Crash ID. Likely a UUID.
|
||||
* @param date (Date) When the crash occurred.
|
||||
*
|
||||
* @return promise<null> Resolved when the store has been saved.
|
||||
*/
|
||||
addCrash: function (processType, crashType, id, date) {
|
||||
return Task.spawn(function* () {
|
||||
let store = yield this._getStore();
|
||||
if (store.addCrash(processType, crashType, id, date)) {
|
||||
yield store.save();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtain the paths of all unprocessed events files.
|
||||
*
|
||||
@ -389,10 +426,9 @@ this.CrashManager.prototype = Object.freeze({
|
||||
// Do not change the format of an existing type. Instead, invent a new
|
||||
// type.
|
||||
|
||||
// type in event file => [processType, crashType]
|
||||
let eventMap = {
|
||||
"crash.main.1": "addMainProcessCrash",
|
||||
"crash.plugin.1": "addPluginCrash",
|
||||
"hang.plugin.1": "addPluginHang",
|
||||
"crash.main.1": ["main", "crash"],
|
||||
};
|
||||
|
||||
if (type in eventMap) {
|
||||
@ -403,7 +439,7 @@ this.CrashManager.prototype = Object.freeze({
|
||||
return this.EVENT_FILE_ERROR_MALFORMED;
|
||||
}
|
||||
|
||||
store[eventMap[type]](payload, date);
|
||||
store.addCrash(...eventMap[type], payload, date);
|
||||
return this.EVENT_FILE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -573,15 +609,6 @@ function CrashStore(storeDir, telemetrySizeKey) {
|
||||
}
|
||||
|
||||
CrashStore.prototype = Object.freeze({
|
||||
// A crash that occurred in the main process.
|
||||
TYPE_MAIN_CRASH: "main-crash",
|
||||
|
||||
// A crash in a plugin process.
|
||||
TYPE_PLUGIN_CRASH: "plugin-crash",
|
||||
|
||||
// A hang in a plugin process.
|
||||
TYPE_PLUGIN_HANG: "plugin-hang",
|
||||
|
||||
// Maximum number of events to store per day. This establishes a
|
||||
// ceiling on the per-type/per-day records that will be stored.
|
||||
HIGH_WATER_DAILY_THRESHOLD: 100,
|
||||
@ -841,23 +868,33 @@ CrashStore.prototype = Object.freeze({
|
||||
* Returns the crash record if we're allowed to store it or null
|
||||
* if we've hit the high water mark.
|
||||
*
|
||||
* @param processType
|
||||
* (string) One of the PROCESS_TYPE constants.
|
||||
* @param crashType
|
||||
* (string) One of the CRASH_TYPE constants.
|
||||
* @param id
|
||||
* (string) The crash ID.
|
||||
* @param type
|
||||
* (string) One of the this.TYPE_* constants describing the crash type.
|
||||
* @param date
|
||||
* (Date) When this crash occurred.
|
||||
*
|
||||
* @return null | object crash record
|
||||
*/
|
||||
_ensureCrashRecord: function (id, type, date) {
|
||||
_ensureCrashRecord: function (processType, crashType, id, date) {
|
||||
if (!id) {
|
||||
// Crashes are keyed on ID, so it's not really helpful to store crashes
|
||||
// without IDs.
|
||||
return null;
|
||||
}
|
||||
|
||||
let day = dateToDays(date);
|
||||
this._ensureCountsForDay(day);
|
||||
|
||||
let type = processType + "-" + crashType;
|
||||
let count = (this._countsByDay.get(day).get(type) || 0) + 1;
|
||||
this._countsByDay.get(day).set(type, count);
|
||||
|
||||
if (count > this.HIGH_WATER_DAILY_THRESHOLD && type != this.TYPE_MAIN_CRASH) {
|
||||
if (count > this.HIGH_WATER_DAILY_THRESHOLD &&
|
||||
processType != CrashManager.prototype.PROCESS_TYPE_MAIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -877,61 +914,23 @@ CrashStore.prototype = Object.freeze({
|
||||
},
|
||||
|
||||
/**
|
||||
* Record the occurrence of a crash in the main process.
|
||||
* Record the occurrence of a crash.
|
||||
*
|
||||
* @param processType (string) One of the PROCESS_TYPE constants.
|
||||
* @param crashType (string) One of the CRASH_TYPE constants.
|
||||
* @param id (string) Crash ID. Likely a UUID.
|
||||
* @param date (Date) When the crash occurred.
|
||||
*/
|
||||
addMainProcessCrash: function (id, date) {
|
||||
this._ensureCrashRecord(id, this.TYPE_MAIN_CRASH, date);
|
||||
},
|
||||
|
||||
/**
|
||||
* Record the occurrence of a crash in a plugin process.
|
||||
*
|
||||
* @param id (string) Crash ID. Likely a UUID.
|
||||
* @param date (Date) When the crash occurred.
|
||||
* @return boolean True if the crash was recorded and false if not.
|
||||
*/
|
||||
addPluginCrash: function (id, date) {
|
||||
this._ensureCrashRecord(id, this.TYPE_PLUGIN_CRASH, date);
|
||||
addCrash: function (processType, crashType, id, date) {
|
||||
return !!this._ensureCrashRecord(processType, crashType, id, date);
|
||||
},
|
||||
|
||||
/**
|
||||
* Record the occurrence of a hang in a plugin process.
|
||||
*
|
||||
* @param id (string) Crash ID. Likely a UUID.
|
||||
* @param date (Date) When the hang was reported.
|
||||
*/
|
||||
addPluginHang: function (id, date) {
|
||||
this._ensureCrashRecord(id, this.TYPE_PLUGIN_HANG, date);
|
||||
},
|
||||
|
||||
get mainProcessCrashes() {
|
||||
getCrashesOfType: function (processType, crashType) {
|
||||
let crashes = [];
|
||||
for (let crash of this.crashes) {
|
||||
if (crash.isMainProcessCrash) {
|
||||
crashes.push(crash);
|
||||
}
|
||||
}
|
||||
|
||||
return crashes;
|
||||
},
|
||||
|
||||
get pluginCrashes() {
|
||||
let crashes = [];
|
||||
for (let crash of this.crashes) {
|
||||
if (crash.isPluginCrash) {
|
||||
crashes.push(crash);
|
||||
}
|
||||
}
|
||||
|
||||
return crashes;
|
||||
},
|
||||
|
||||
get pluginHangs() {
|
||||
let crashes = [];
|
||||
for (let crash of this.crashes) {
|
||||
if (crash.isPluginHang) {
|
||||
if (crash.isOfType(processType, crashType)) {
|
||||
crashes.push(crash);
|
||||
}
|
||||
}
|
||||
@ -984,16 +983,8 @@ CrashRecord.prototype = Object.freeze({
|
||||
return this._o.type;
|
||||
},
|
||||
|
||||
get isMainProcessCrash() {
|
||||
return this._o.type == CrashStore.prototype.TYPE_MAIN_CRASH;
|
||||
},
|
||||
|
||||
get isPluginCrash() {
|
||||
return this._o.type == CrashStore.prototype.TYPE_PLUGIN_CRASH;
|
||||
},
|
||||
|
||||
get isPluginHang() {
|
||||
return this._o.type == CrashStore.prototype.TYPE_PLUGIN_HANG;
|
||||
isOfType: function (processType, crashType) {
|
||||
return processType + "-" + crashType == this.type;
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,39 @@ this.CrashService = function () {};
|
||||
|
||||
CrashService.prototype = Object.freeze({
|
||||
classID: Components.ID("{92668367-1b17-4190-86b2-1061b2179744}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsICrashService,
|
||||
Ci.nsIObserver,
|
||||
]),
|
||||
|
||||
addCrash: function (processType, crashType, id) {
|
||||
switch (processType) {
|
||||
case Ci.nsICrashService.PROCESS_TYPE_MAIN:
|
||||
processType = Services.crashmanager.PROCESS_TYPE_MAIN;
|
||||
break;
|
||||
case Ci.nsICrashService.PROCESS_TYPE_CONTENT:
|
||||
processType = Services.crashmanager.PROCESS_TYPE_CONTENT;
|
||||
break;
|
||||
case Ci.nsICrashService.PROCESS_TYPE_PLUGIN:
|
||||
processType = Services.crashmanager.PROCESS_TYPE_PLUGIN;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unrecognized PROCESS_TYPE: " + processType);
|
||||
}
|
||||
|
||||
switch (crashType) {
|
||||
case Ci.nsICrashService.CRASH_TYPE_CRASH:
|
||||
crashType = Services.crashmanager.CRASH_TYPE_CRASH;
|
||||
break;
|
||||
case Ci.nsICrashService.CRASH_TYPE_HANG:
|
||||
crashType = Services.crashmanager.CRASH_TYPE_HANG;
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unrecognized CRASH_TYPE: " + crashType);
|
||||
}
|
||||
|
||||
Services.crashmanager.addCrash(processType, crashType, id, new Date());
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
switch (topic) {
|
||||
|
@ -60,6 +60,11 @@ Each subsection documents the different types of crash events that may be
|
||||
produced. Each section name corresponds to the first line of the crash
|
||||
event file.
|
||||
|
||||
Currently only main process crashes produce event files. Because crashes and
|
||||
hangs in child processes can be easily recorded by the main process, we do not
|
||||
foresee the need for writing event files for child processes, design
|
||||
considerations below notwithstanding.
|
||||
|
||||
crash.main.1
|
||||
^^^^^^^^^^^^
|
||||
|
||||
@ -69,20 +74,6 @@ The payload of this event is the string crash ID, very likely a UUID.
|
||||
There should be ``UUID.dmp`` and ``UUID.extra`` files on disk, saved by
|
||||
Breakpad.
|
||||
|
||||
crash.plugin.1
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
This event is produced when a plugin process crashes.
|
||||
|
||||
The payload is identical to ``crash.main.1``'s.
|
||||
|
||||
hang.plugin.1
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
This event is produced when a plugin process hangs.
|
||||
|
||||
The payload is identical to ``crash.main.1``'s.
|
||||
|
||||
Aggregated Event Log
|
||||
====================
|
||||
|
||||
|
@ -16,3 +16,9 @@ EXTRA_JS_MODULES += [
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
|
||||
|
||||
XPIDL_MODULE = 'toolkit_crashservice'
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsICrashService.idl',
|
||||
]
|
||||
|
28
toolkit/components/crashes/nsICrashService.idl
Normal file
28
toolkit/components/crashes/nsICrashService.idl
Normal file
@ -0,0 +1,28 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(a1845b69-28f4-43db-be6e-02eb15a45481)]
|
||||
interface nsICrashService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Records the occurrence of a crash.
|
||||
*
|
||||
* @param processType
|
||||
* One of the PROCESS_TYPE constants defined below.
|
||||
* @param crashType
|
||||
* One of the CRASH_TYPE constants defined below.
|
||||
* @param id
|
||||
* Crash ID. Likely a UUID.
|
||||
*/
|
||||
void addCrash(in long processType, in long crashType, in AString id);
|
||||
|
||||
const long PROCESS_TYPE_MAIN = 0;
|
||||
const long PROCESS_TYPE_CONTENT = 1;
|
||||
const long PROCESS_TYPE_PLUGIN = 2;
|
||||
|
||||
const long CRASH_TYPE_CRASH = 0;
|
||||
const long CRASH_TYPE_HANG = 1;
|
||||
};
|
@ -166,7 +166,7 @@ add_task(function* test_prune_old() {
|
||||
let oldDate = new Date(Date.now() - 86400000);
|
||||
let newDate = new Date(Date.now() - 10000);
|
||||
yield m.createEventsFile("1", "crash.main.1", oldDate, "id1");
|
||||
yield m.createEventsFile("2", "crash.plugin.1", newDate, "id2");
|
||||
yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH, "id2", newDate);
|
||||
|
||||
yield m.aggregateEventsFiles();
|
||||
|
||||
@ -225,39 +225,7 @@ add_task(function* test_multiline_crash_id_rejected() {
|
||||
Assert.equal(crashes.length, 0);
|
||||
});
|
||||
|
||||
add_task(function* test_plugin_crash_event_file() {
|
||||
let m = yield getManager();
|
||||
yield m.createEventsFile("1", "crash.plugin.1", DUMMY_DATE, "id1");
|
||||
let count = yield m.aggregateEventsFiles();
|
||||
Assert.equal(count, 1);
|
||||
|
||||
let crashes = yield m.getCrashes();
|
||||
Assert.equal(crashes.length, 1);
|
||||
Assert.equal(crashes[0].id, "id1");
|
||||
Assert.equal(crashes[0].type, "plugin-crash");
|
||||
Assert.deepEqual(crashes[0].crashDate, DUMMY_DATE);
|
||||
|
||||
count = yield m.aggregateEventsFiles();
|
||||
Assert.equal(count, 0);
|
||||
});
|
||||
|
||||
add_task(function* test_plugin_hang_event_file() {
|
||||
let m = yield getManager();
|
||||
yield m.createEventsFile("1", "hang.plugin.1", DUMMY_DATE, "id1");
|
||||
let count = yield m.aggregateEventsFiles();
|
||||
Assert.equal(count, 1);
|
||||
|
||||
let crashes = yield m.getCrashes();
|
||||
Assert.equal(crashes.length, 1);
|
||||
Assert.equal(crashes[0].id, "id1");
|
||||
Assert.equal(crashes[0].type, "plugin-hang");
|
||||
Assert.deepEqual(crashes[0].crashDate, DUMMY_DATE);
|
||||
|
||||
count = yield m.aggregateEventsFiles();
|
||||
Assert.equal(count, 0);
|
||||
});
|
||||
|
||||
// Excessive amounts of files should be processed properly.
|
||||
// Main process crashes should be remembered beyond the high water mark.
|
||||
add_task(function* test_high_water_mark() {
|
||||
let m = yield getManager();
|
||||
|
||||
@ -265,15 +233,74 @@ add_task(function* test_high_water_mark() {
|
||||
|
||||
for (let i = 0; i < store.HIGH_WATER_DAILY_THRESHOLD + 1; i++) {
|
||||
yield m.createEventsFile("m" + i, "crash.main.1", DUMMY_DATE, "m" + i);
|
||||
yield m.createEventsFile("pc" + i, "crash.plugin.1", DUMMY_DATE, "pc" + i);
|
||||
yield m.createEventsFile("ph" + i, "hang.plugin.1", DUMMY_DATE, "ph" + i);
|
||||
}
|
||||
|
||||
let count = yield m.aggregateEventsFiles();
|
||||
Assert.equal(count, 3 * bsp.CrashStore.prototype.HIGH_WATER_DAILY_THRESHOLD + 3);
|
||||
Assert.equal(count, bsp.CrashStore.prototype.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
|
||||
// Need to fetch again in case the first one was garbage collected.
|
||||
store = yield m._getStore();
|
||||
// +1 is for preserved main process crash.
|
||||
Assert.equal(store.crashesCount, 3 * store.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
|
||||
Assert.equal(store.crashesCount, store.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
});
|
||||
|
||||
add_task(function* test_addCrash() {
|
||||
let m = yield getManager();
|
||||
|
||||
let crashes = yield m.getCrashes();
|
||||
Assert.equal(crashes.length, 0);
|
||||
|
||||
yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
|
||||
"main-crash", DUMMY_DATE);
|
||||
yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_HANG,
|
||||
"main-hang", DUMMY_DATE);
|
||||
yield m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH,
|
||||
"content-crash", DUMMY_DATE);
|
||||
yield m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG,
|
||||
"content-hang", DUMMY_DATE);
|
||||
yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH,
|
||||
"plugin-crash", DUMMY_DATE);
|
||||
yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_HANG,
|
||||
"plugin-hang", DUMMY_DATE);
|
||||
|
||||
crashes = yield m.getCrashes();
|
||||
Assert.equal(crashes.length, 6);
|
||||
|
||||
let map = new Map(crashes.map(crash => [crash.id, crash]));
|
||||
|
||||
let crash = map.get("main-crash");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_CRASH);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH));
|
||||
|
||||
crash = map.get("main-hang");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_HANG);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_HANG));
|
||||
|
||||
crash = map.get("content-crash");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_CRASH);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH));
|
||||
|
||||
crash = map.get("content-hang");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_HANG);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG));
|
||||
|
||||
crash = map.get("plugin-crash");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_PLUGIN + "-" + m.CRASH_TYPE_CRASH);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH));
|
||||
|
||||
crash = map.get("plugin-hang");
|
||||
Assert.ok(!!crash);
|
||||
Assert.equal(crash.crashDate, DUMMY_DATE);
|
||||
Assert.equal(crash.type, m.PROCESS_TYPE_PLUGIN + "-" + m.CRASH_TYPE_HANG);
|
||||
Assert.ok(crash.isOfType(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_HANG));
|
||||
});
|
||||
|
@ -13,6 +13,14 @@ let bsp = Cu.import("resource://gre/modules/CrashManager.jsm", this);
|
||||
Cu.import("resource://gre/modules/osfile.jsm", this);
|
||||
Cu.import("resource://gre/modules/Task.jsm", this);
|
||||
|
||||
const {
|
||||
PROCESS_TYPE_MAIN,
|
||||
PROCESS_TYPE_CONTENT,
|
||||
PROCESS_TYPE_PLUGIN,
|
||||
CRASH_TYPE_CRASH,
|
||||
CRASH_TYPE_HANG,
|
||||
} = CrashManager.prototype;
|
||||
|
||||
const CrashStore = bsp.CrashStore;
|
||||
|
||||
let STORE_DIR_COUNT = 0;
|
||||
@ -45,7 +53,7 @@ add_task(function test_add_crash() {
|
||||
|
||||
Assert.equal(s.crashesCount, 0);
|
||||
let d = new Date(Date.now() - 5000);
|
||||
s.addMainProcessCrash("id1", d);
|
||||
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d));
|
||||
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
@ -56,7 +64,9 @@ add_task(function test_add_crash() {
|
||||
Assert.equal(c.id, "id1", "ID set properly.");
|
||||
Assert.equal(c.crashDate.getTime(), d.getTime(), "Date set.");
|
||||
|
||||
s.addMainProcessCrash("id2", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
});
|
||||
|
||||
@ -67,8 +77,10 @@ add_task(function test_save_load() {
|
||||
|
||||
let d1 = new Date();
|
||||
let d2 = new Date(d1.getTime() - 10000);
|
||||
s.addMainProcessCrash("id1", d1);
|
||||
s.addMainProcessCrash("id2", d2);
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d1) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", d2)
|
||||
);
|
||||
|
||||
yield s.save();
|
||||
|
||||
@ -101,72 +113,179 @@ add_task(function test_corrupt_json() {
|
||||
add_task(function* test_add_main_crash() {
|
||||
let s = yield getStore();
|
||||
|
||||
s.addMainProcessCrash("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, bsp.CrashStore.prototype.TYPE_MAIN_CRASH);
|
||||
Assert.ok(c.isMainProcessCrash);
|
||||
Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH));
|
||||
|
||||
s.addMainProcessCrash("id2", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
// Duplicate.
|
||||
s.addMainProcessCrash("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.equal(s.mainProcessCrashes.length, 2);
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_main_hang() {
|
||||
let s = yield getStore();
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG));
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_content_crash() {
|
||||
let s = yield getStore();
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH));
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_content_hang() {
|
||||
let s = yield getStore();
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG));
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_plugin_crash() {
|
||||
let s = yield getStore();
|
||||
|
||||
s.addPluginCrash("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, bsp.CrashStore.prototype.TYPE_PLUGIN_CRASH);
|
||||
Assert.ok(c.isPluginCrash);
|
||||
Assert.equal(c.type, PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH));
|
||||
|
||||
s.addPluginCrash("id2", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
s.addPluginCrash("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.equal(s.pluginCrashes.length, 2);
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_plugin_hang() {
|
||||
let s = yield getStore();
|
||||
|
||||
s.addPluginHang("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 1);
|
||||
|
||||
let c = s.crashes[0];
|
||||
Assert.ok(c.crashDate);
|
||||
Assert.equal(c.type, bsp.CrashStore.prototype.TYPE_PLUGIN_HANG);
|
||||
Assert.ok(c.isPluginHang);
|
||||
Assert.equal(c.type, PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG);
|
||||
Assert.ok(c.isOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG));
|
||||
|
||||
s.addPluginHang("id2", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id2", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
s.addPluginHang("id1", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id1", new Date())
|
||||
);
|
||||
Assert.equal(s.crashesCount, 2);
|
||||
|
||||
Assert.equal(s.pluginHangs.length, 2);
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2);
|
||||
});
|
||||
|
||||
add_task(function* test_add_mixed_types() {
|
||||
let s = yield getStore();
|
||||
|
||||
s.addMainProcessCrash("main", new Date());
|
||||
s.addPluginCrash("pcrash", new Date());
|
||||
s.addPluginHang("phang", new Date());
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mcrash", new Date()) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mhang", new Date()) &&
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "ccrash", new Date()) &&
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "chang", new Date()) &&
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pcrash", new Date()) &&
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "phang", new Date())
|
||||
);
|
||||
|
||||
Assert.equal(s.crashesCount, 3);
|
||||
Assert.equal(s.crashesCount, 6);
|
||||
|
||||
yield s.save();
|
||||
|
||||
@ -175,11 +294,20 @@ add_task(function* test_add_mixed_types() {
|
||||
|
||||
yield s.load();
|
||||
|
||||
Assert.equal(s.crashesCount, 3);
|
||||
Assert.equal(s.crashesCount, 6);
|
||||
|
||||
Assert.equal(s.mainProcessCrashes.length, 1);
|
||||
Assert.equal(s.pluginCrashes.length, 1);
|
||||
Assert.equal(s.pluginHangs.length, 1);
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 1);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 1);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 1);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 1);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 1);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 1);
|
||||
});
|
||||
|
||||
// Crashes added beyond the high water mark behave properly.
|
||||
@ -189,32 +317,87 @@ add_task(function* test_high_water() {
|
||||
let d1 = new Date(2014, 0, 1, 0, 0, 0);
|
||||
let d2 = new Date(2014, 0, 2, 0, 0, 0);
|
||||
|
||||
for (let i = 0; i < s.HIGH_WATER_DAILY_THRESHOLD + 1; i++) {
|
||||
s.addMainProcessCrash("m1" + i, d1);
|
||||
s.addMainProcessCrash("m2" + i, d2);
|
||||
s.addPluginCrash("pc1" + i, d1);
|
||||
s.addPluginCrash("pc2" + i, d2);
|
||||
s.addPluginHang("ph1" + i, d1);
|
||||
s.addPluginHang("ph2" + i, d2);
|
||||
let i = 0;
|
||||
for (; i < s.HIGH_WATER_DAILY_THRESHOLD; i++) {
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2) &&
|
||||
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2) &&
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2) &&
|
||||
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc2" + i, d2) &&
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph2" + i, d2)
|
||||
);
|
||||
}
|
||||
|
||||
// We preserve main process crashes. Plugin crashes and hangs beyond should
|
||||
// be discarded.
|
||||
Assert.equal(s.crashesCount, 6 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
|
||||
Assert.equal(s.mainProcessCrashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
|
||||
Assert.equal(s.pluginCrashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
Assert.equal(s.pluginHangs.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
Assert.ok(
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
|
||||
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2)
|
||||
);
|
||||
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2));
|
||||
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc1" + i, d1));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc2" + i, d2));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph1" + i, d1));
|
||||
Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph2" + i, d2));
|
||||
|
||||
// We preserve main process crashes and hangs. Content and plugin crashes and
|
||||
// hangs beyond should be discarded.
|
||||
Assert.equal(s.crashesCount, 12 * s.HIGH_WATER_DAILY_THRESHOLD + 4);
|
||||
|
||||
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
|
||||
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
|
||||
Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
|
||||
|
||||
// But raw counts should be preserved.
|
||||
let day1 = bsp.dateToDays(d1);
|
||||
let day2 = bsp.dateToDays(d2);
|
||||
Assert.ok(s._countsByDay.has(day1));
|
||||
Assert.ok(s._countsByDay.has(day2));
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_MAIN_CRASH),
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_PLUGIN_CRASH),
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_PLUGIN_HANG),
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
|
||||
yield s.save();
|
||||
@ -222,10 +405,25 @@ add_task(function* test_high_water() {
|
||||
|
||||
Assert.ok(s._countsByDay.has(day1));
|
||||
Assert.ok(s._countsByDay.has(day2));
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_MAIN_CRASH),
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_PLUGIN_CRASH),
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).get(s.TYPE_PLUGIN_HANG),
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
Assert.equal(s._countsByDay.get(day1).
|
||||
get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG),
|
||||
s.HIGH_WATER_DAILY_THRESHOLD + 1);
|
||||
});
|
||||
|
@ -468,7 +468,7 @@
|
||||
<xul:menupopup anonid="menupopup"
|
||||
xbl:inherits="oncommand=menucommand">
|
||||
<children/>
|
||||
<xul:menuitem class="menuitem-iconic popup-notification-closeitem close-icon"
|
||||
<xul:menuitem class="menuitem-iconic popup-notification-closeitem"
|
||||
label="&closeNotificationItem.label;"
|
||||
xbl:inherits="oncommand=closeitemcommand,hidden=hidenotnow"/>
|
||||
</xul:menupopup>
|
||||
|
@ -37,6 +37,6 @@ add_task(function* test_main_process_crash() {
|
||||
let crashes = yield cm.getCrashes();
|
||||
Assert.equal(crashes.length, 1);
|
||||
let crash = crashes[0];
|
||||
Assert.ok(crash.isMainProcessCrash);
|
||||
Assert.ok(crash.isOfType(cm.PROCESS_TYPE_MAIN, cm.CRASH_TYPE_CRASH));
|
||||
Assert.equal(crash.id + ".dmp", basename, "ID recorded properly");
|
||||
});
|
||||
|
201
toolkit/devtools/qrcode/decoder/LICENSE
Normal file
201
toolkit/devtools/qrcode/decoder/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
3849
toolkit/devtools/qrcode/decoder/index.js
Normal file
3849
toolkit/devtools/qrcode/decoder/index.js
Normal file
File diff suppressed because it is too large
Load Diff
11
toolkit/devtools/qrcode/decoder/moz.build
Normal file
11
toolkit/devtools/qrcode/decoder/moz.build
Normal file
@ -0,0 +1,11 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
JS_MODULES_PATH = 'modules/devtools/qrcode/decoder'
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'index.js',
|
||||
]
|
@ -597,6 +597,7 @@ var qrcode = function() {
|
||||
Q : 3,
|
||||
H : 2
|
||||
};
|
||||
// mozilla: Add module support
|
||||
exports.QRErrorCorrectLevel = QRErrorCorrectLevel;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -1133,7 +1134,7 @@ var qrcode = function() {
|
||||
return _this;
|
||||
}();
|
||||
|
||||
// jryans: Add module support
|
||||
// mozilla: Add module support
|
||||
exports.QRRSBlock = QRRSBlock;
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@ -1669,5 +1670,5 @@ var qrcode = function() {
|
||||
return qrcode;
|
||||
}();
|
||||
|
||||
// jryans: Add module support
|
||||
// mozilla: Add module support
|
||||
exports.Encoder = qrcode;
|
||||
|
@ -4,7 +4,23 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
let { Encoder, QRRSBlock, QRErrorCorrectLevel } = require("./encoder/index");
|
||||
const { Cu } = require("chrome");
|
||||
const { Promise: promise } =
|
||||
Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
|
||||
// Lazily require encoder and decoder in case only one is needed
|
||||
Object.defineProperty(this, "Encoder", {
|
||||
get: () => require("./encoder/index").Encoder
|
||||
});
|
||||
Object.defineProperty(this, "QRRSBlock", {
|
||||
get: () => require("./encoder/index").QRRSBlock
|
||||
});
|
||||
Object.defineProperty(this, "QRErrorCorrectLevel", {
|
||||
get: () => require("./encoder/index").QRErrorCorrectLevel
|
||||
});
|
||||
Object.defineProperty(this, "decoder", {
|
||||
get: () => require("./decoder/index")
|
||||
});
|
||||
|
||||
/**
|
||||
* There are many "versions" of QR codes, which describes how many dots appear
|
||||
@ -60,3 +76,28 @@ exports.encodeToDataURI = function(message, quality, version) {
|
||||
encoder.make();
|
||||
return encoder.createImgData();
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple wrapper around the underlying decoder's API.
|
||||
* @param string URI
|
||||
* URI of an image of a QR code
|
||||
* @return Promise
|
||||
* The promise will be resolved with a string, which is the data inside
|
||||
* the QR code.
|
||||
*/
|
||||
exports.decodeFromURI = function(URI) {
|
||||
let deferred = promise.defer();
|
||||
decoder.decodeFromURI(URI, deferred.resolve, deferred.reject);
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a QR code that has been drawn to a canvas element.
|
||||
* @param Canvas canvas
|
||||
* <canvas> element to read from
|
||||
* @return string
|
||||
* The data inside the QR code
|
||||
*/
|
||||
exports.decodeFromCanvas = function(canvas) {
|
||||
return decoder.decodeFromCanvas(canvas);
|
||||
};
|
@ -5,13 +5,15 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
PARALLEL_DIRS += [
|
||||
'decoder',
|
||||
'encoder'
|
||||
]
|
||||
|
||||
JS_MODULES_PATH = 'modules/devtools/qrcode'
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'qrcode.js',
|
||||
'index.js',
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
||||
MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
|
||||
|
1
toolkit/devtools/qrcode/tests/mochitest/chrome.ini
Normal file
1
toolkit/devtools/qrcode/tests/mochitest/chrome.ini
Normal file
@ -0,0 +1 @@
|
||||
[test_decode.html]
|
69
toolkit/devtools/qrcode/tests/mochitest/test_decode.html
Normal file
69
toolkit/devtools/qrcode/tests/mochitest/test_decode.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test decoding a simple message
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test decoding a simple message</title>
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript;version=1.8">
|
||||
window.onload = function() {
|
||||
const { utils: Cu } = Components;
|
||||
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
|
||||
const { require } = devtools;
|
||||
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
|
||||
const { Promise: promise } =
|
||||
Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
|
||||
const QR = require("devtools/toolkit/qrcode/index");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const testImage =
|
||||
"data:image/gif;base64,R0lGODdhOgA6AIAAAAAAAP///ywAAAAAOgA6AAAC" +
|
||||
"/4yPqcvtD6OctNqLs968+w+G4gKU5nkaKKquLuW+QVy2tAkDTj3rfQts8CRDko" +
|
||||
"+HPPoYRUgy9YsyldDm44mLWhHYZM6W7WaDqyCRGkZDySxpRGw2sqvLt1q5w/fo" +
|
||||
"XyE6vnUQOJUHBlinMGh046V1F5PDqNcoqcgBOWKBKbK2N+aY+Ih49VkmqMcl2l" +
|
||||
"dkhZUK1umE6jZXJ2ZJaujZaRqH4bpb2uZrJxvIt4Ebe9qoYYrJOsw8apz2bCut" +
|
||||
"m9kqDcw52uuImyr5Oh1KXH1jrn2anuunywtODU/o2c6teceW39ZcLFg/fNMo1b" +
|
||||
"t3jVw2dwTPwJq1KYG3gAklCgu37yGxeScYKyiCc+7DR34hPVQiuQ7UhJMagyEb" +
|
||||
"lymmzJk0a9q8iTOnzp0NCgAAOw==";
|
||||
|
||||
Task.spawn(function() {
|
||||
let result = yield QR.decodeFromURI(testImage);
|
||||
is(result, "HELLO", "Decoded data URI result matches");
|
||||
let canvas = yield drawToCanvas(testImage);
|
||||
result = QR.decodeFromCanvas(canvas);
|
||||
is(result, "HELLO", "Decoded canvas result matches");
|
||||
}).then(SimpleTest.finish, ok.bind(null, false));
|
||||
|
||||
function drawToCanvas(src) {
|
||||
let deferred = promise.defer();
|
||||
let canvas = document.createElement("canvas");
|
||||
let context = canvas.getContext("2d");
|
||||
let image = new Image();
|
||||
|
||||
image.onload = () => {
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
context.drawImage(image, 0, 0);
|
||||
deferred.resolve(canvas);
|
||||
};
|
||||
image.src = src;
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -10,7 +10,7 @@ const { utils: Cu } = Components;
|
||||
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
|
||||
const { require } = devtools;
|
||||
|
||||
const QR = require("devtools/toolkit/qrcode/qrcode");
|
||||
const QR = require("devtools/toolkit/qrcode/index");
|
||||
|
||||
function run_test() {
|
||||
let imgData = QR.encodeToDataURI("HELLO", "L");
|
||||
|
Loading…
Reference in New Issue
Block a user