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 / ext-devtools.js
Created October 7, 2016 14:03
WebExtension devtools API (in the new webext-oop style)
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
/* global getTabIdForToolbox */
/**
* This module provides helpers used by the other specialized `ext-devtools-*.js` modules
* and the implementation of the `devtools_page`.
*/
@rpl
rpl / output.txt
Created September 8, 2016 15:15
weird error on web-ext lint functional test with demand(0,0, ...)
Usage: ./bin/web-ext [options] addon-package-or-dir
Add-ons Linter (JS Edition) v0.15.3
Options:
--version Show version number [boolean]
--source-dir, -s Web extension source directory.
[string] [required] [default: "/zfs-mordor/work/webext/tools/web-ext"]
--artifacts-dir, -a Directory where artifacts will be saved.
@rpl
rpl / test.program.js
Created September 8, 2016 14:29
fix web-ext test
it('throws an error about unknown sub-command options', () => {
const program = new Program(['thing', '--nope'])
.command('thing', '', () => {});
return run(program)
.then(makeSureItFails())
.catch((error) => {
// Again, yargs calls this an argument not an option for some reason.
assert.match(error.message, /Unknown argument: --nope/);
});
});
@rpl
rpl / actor.js
Last active August 26, 2016 13:59
webext devtools api internals
/* 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/. */
"use strict";
const protocol = require("devtools/shared/protocol");
const {Ci} = require("chrome");
const Services = require("Services");
@rpl
rpl / example.js
Created August 10, 2016 19:47
use a flow type to pass config data through a Promise chain
type RunConfig = {
runner: ExtensionRunner,
profile: FirefoxProfile,
client?: RemoteFirefox,
addonId?: string,
firefox?: FirefoxProcess,
};
...
@rpl
rpl / LegacyExtensionUtils.jsm
Created August 4, 2016 17:05
Hybrid Addon Helpers - Proposal B
/* 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/. */
"use strict";
this.EXPORTED_SYMBOLS = ["LegacyExtensionsUtils"];
/* exported LegacyExtensionsUtils */
@rpl
rpl / contentscript.js
Last active August 30, 2017 16:44
jquery inside a webextension content script
$(function() {
alert('You are on github')
// Load the options.html into the page
var optionsURL = chrome.extension.getURL("options.html");
$.get(optionsURL, function(data){
// the xml data has been received
console.log("OPTION.html data ", data);
// data is a string on Chrome
@rpl
rpl / mozconfig.artifact-debug
Created April 21, 2016 16:51
mozconfig file for experimental debug artifacts
# Automatically download and use compiled C++ components:
ac_add_options --enable-artifact-builds --debug-artifact
# Write build artifacts to:
mk_add_options MOZ_OBJDIR=./objdir-frontend-debug
diff --git a/toolkit/components/extensions/ext-notifications.js b/toolkit/components/extensions/ext-notifications.js
--- a/toolkit/components/extensions/ext-notifications.js
+++ b/toolkit/components/extensions/ext-notifications.js
@@ -47,24 +47,31 @@ Notification.prototype = {
svc.closeAlert(this.id);
} catch (e) {
// This will fail if the OS doesn't support this function.
}
notificationsMap.get(this.extension).delete(this.id);
},
@rpl
rpl / tweak-bug-1207394-test.patch
Created April 14, 2016 21:37
share content scripts helper function in WebExtensions mochitest
diff --git a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html
@@ -18,47 +18,45 @@
SimpleTest.registerCleanupFunction(() => {
SpecialPowers.clearUserPref("security.mixed_content.block_display_content");
});
let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
"ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");