This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main.js | |
| PageMod({ | |
| onAttach: function(worker) { | |
| worker.addEventListener("message", function(event){ | |
| if (event.origin === "good.com") // page script | |
| event.source.postMessage(event.data + " addon!", "good.com"); | |
| else if(event.origin === worker.origin) // content script | |
| event.source.postMessage("content script, hello!", worker.origin); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let cm = require("sdk/context-menu"); | |
| let item = cm.Item({ | |
| label: "My Menu Item", | |
| context: cm.SelectionContext() | |
| }); | |
| require("sdk/selection").on("select", function(){ | |
| item.label = this.text | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var proto = Element.prototype; | |
| var slice = Function.call.bind(Array.prototype.slice); | |
| var matches = Function.call.bind(proto.matchesSelector || | |
| proto.mozMatchesSelector || proto.webkitMatchesSelector || | |
| proto.msMatchesSelector || proto.oMatchesSelector); | |
| // Returns true if a DOM Element matches a cssRule | |
| var elementMatchCSSRule = function(element, cssRule) { | |
| return matches(element, cssRule.selectorText); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let { Button } = require("sdk/ui"); | |
| let button = Button({ | |
| id: "my-button", | |
| // assuming automatically `data` folder for "./" | |
| image: "./beer.png", | |
| // required as tooltip and overflow | |
| label: "My Button", | |
| type: "checked" | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/sdk/deprecated/unit-test-finder.js b/lib/sdk/deprecated/unit-test-finder.js | |
| index 0d13265..c2268d5 100644 | |
| --- a/lib/sdk/deprecated/unit-test-finder.js | |
| +++ b/lib/sdk/deprecated/unit-test-finder.js | |
| @@ -55,8 +55,20 @@ TestFinder.prototype = { | |
| function(suite) { | |
| // Load each test file as a main module in its own loader instance | |
| // `suite` is defined by cuddlefish/manifest.py:ManifestBuilder.build | |
| - var loader = Loader(module); | |
| - var module = cuddlefish.main(loader, suite); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Open a plain dialog */ | |
| const { getActiveTab, setTabURL } = require('sdk/tabs/utils'); | |
| const { open } = require('sdk/window/helpers'); | |
| const { data } = require('sdk/self'); | |
| const url = data.url('foo.html'); | |
| open("", { | |
| features: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add `contentType` to page-mod: | |
| // https://bugzilla.mozilla.org/show_bug.cgi?id=788224 | |
| // current API: | |
| // all the http/https urls | |
| PageMod({ | |
| include: '*', // can take string | |
| contentScript: 'console.log("hello")' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let { events: windowEvents } = require('sdk/window/events'); | |
| let { on } = require('sdk/event/core'); | |
| let { filter } = require('sdk/event/utils'); | |
| let ready = filter(windowEvents, ({type}) => type === 'DOMContentLoaded'); | |
| let certificateWindows = filter(ready, ({target}) => | |
| target.document.documentElement.mozMatchesSelector('dialog#certDetails')); | |
| on(certificateWindows, 'data', ({target: window}) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { ActionButton } = require("sdk/ui/button/action"); | |
| const { browserWindows } = require("sdk/windows"); | |
| let button = ActionButton({ | |
| id: "reverse-tabs", | |
| label: "Reverse Tab Order", | |
| icon: { | |
| // The new APIs use "./" as shortcut for data folder, you don't need | |
| // to require `self` for that purpose. | |
| "16": "./16.png", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { window: { document } } = require('sdk/addon/window'); | |
| const { getTabContentWindow, getActiveTab } = require('sdk/tabs/utils'); | |
| const { getMostRecentBrowserWindow } = require('sdk/window/utils'); | |
| const canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); | |
| document.documentElement.appendChild(canvas); | |
| function captureActiveTab() { | |
| let contentWindow = getTabContentWindow(getActiveTab(getMostRecentBrowserWindow())); |
OlderNewer