Skip to content

Instantly share code, notes, and snippets.

View rpl's full-sized avatar

Luca Greco rpl

  • Mozilla
  • Lecce, Italy
View GitHub Profile
@rpl
rpl / proposal01.patch
Created April 13, 2016 18:41
"rename webNavigation MessageManager message names" proposals
diff --git a/toolkit/modules/addons/WebNavigation.jsm b/toolkit/modules/addons/WebNavigation.jsm
--- a/toolkit/modules/addons/WebNavigation.jsm
+++ b/toolkit/modules/addons/WebNavigation.jsm
@@ -20,23 +20,25 @@ Cu.import("resource://gre/modules/Servic
// onCreatedNavigationTarget, onHistoryStateUpdated
var Manager = {
listeners: new Map(),
init() {
@rpl
rpl / blocked_image_promise_snippet.js
Created April 13, 2016 13:52
wait for blocked or loaded image
let blockedImagePromise = new Promise((resolve, reject) => {
let blockedImage = document.createElement("img");
blockedImage.setAttribute("src", "http://example.com/tests/toolkit/components/extensions/test/mochitest/file_image_bad.png");
let errorListener = () => {
browser.test.succeed("img got blocked as expected");
cleanupListeners();
resolve();
};
let loadListener = () => {
browser.test.fail("img loaded unexpected");
@rpl
rpl / resolve-addon-icon-url.patch
Created April 13, 2016 11:51
resolve addon icon url
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -6990,22 +6990,23 @@ AddonWrapper.prototype = {
icons[32] = icons[48] = this.getResourceURI("icon.png").spec;
}
if (this.hasResource("icon64.png")) {
icons[64] = this.getResourceURI("icon64.png").spec;
}
}
@rpl
rpl / draft-getContentGlobals.patch
Created April 6, 2016 12:41
recognize content scripts on developer toolbox first opened
diff --git a/devtools/server/actors/webbrowser.js b/devtools/server/actors/webbrowser.js
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -30,16 +30,17 @@ loader.lazyRequireGetter(this, "ProcessA
loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
// Assumptions on events module:
// events needs to be dispatched synchronously,
// by calling the listeners in the order or registration.
loader.lazyRequireGetter(this, "events", "sdk/event/core");
@rpl
rpl / index.js
Last active March 31, 2016 13:10
Small Firefox for Android addon which use 'rpl/fennec-addon-preferences-workaround' as a dependency to workaround the preferences issue.
// do your stuff or import your modules
const { on } = require("sdk/system/events");
const { id } = require("sdk/self");
console.log("ADDON ID: ", id);
on(`${id}-cmdPressed`, function ({data}) {
console.log("CMD PRESSED", data);
@rpl
rpl / mozreview_failure.log
Created February 17, 2016 15:42
mozreview UnicodeDecodeError
Are you sure you want to push to remote? (y/n): y
pushing to ssh://reviewboard-hg.mozilla.org/gecko
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files (+1 heads)
remote: recorded push in pushlog
submitting 1 changesets for review
remote: ** unknown exception encountered, please report by visiting
@rpl
rpl / eslint-errors.log
Created February 15, 2016 19:53
eslint errors on test_ext_bookmarks.html
% ./mach eslint toolkit/components/extensions/ browser/components/extensions/ ~/work/mozlab/mozilla-central-hg
0:00.12 Running /usr/local/bin/eslint
0:00.12 /usr/local/bin/eslint --plugin html --ext [.js,.jsm,.jsx,.xml,.html] toolkit/components/extensions/ browser/components/extensions/
/zfs-tardis/mozlab/desktop/mozilla-central-hg/toolkit/components/extensions/test/mochitest/test_ext_bookmarks.html
92:4 warning Block must not be padded by blank lines padded-blocks
94:9 error Expected indentation of 6 space characters but found 8 indent
95:9 error Expected indentation of 6 space characters but found 8 indent
96:9 error Expected indentation of 6 space characters but found 8 indent
97:9 error Expected indentation of 6 space characters but found 8 indent
@rpl
rpl / ext-tabs.js
Last active January 18, 2016 21:03
tabs.duplicate
duplicate: function(tabId, callback) {
let tab = TabManager.getTab(tabId);
// Ignore invalid tab ids.
if (!tab) {
if (callback) {
runSafe(context, callback, undefined);
}
return;
}
@rpl
rpl / httpd.js
Last active December 18, 2015 17:55
test-load-httpd firefox addon
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* 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/. */
/*
* An implementation of an HTTP server both as a loadable script and as an XPCOM
* component. See the accompanying README file for user documentation on
* httpd.js.
TEST-PASS | leakcheck | default process: no leaks detected!
== BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, tab process 24550
|<----------------Class--------------->|<-----Bytes------>|<----Objects---->|
| | Per-Inst Leaked| Total Rem|
0 |TOTAL | 56 4640| 152828 33|
11 |AsyncTransactionTrackersHolder | 72 72| 2 1|
42 |CompositorChild | 880 880| 1 1|
44 |CondVar | 40 120| 25 3|