addon-sdk/source/examples/toolbar-api/lib/main.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     4 "use strict";
     6 const { Toolbar } = require("sdk/ui/toolbar");
     7 const { Frame } = require("sdk/ui/frame");
     8 const { ActionButton } = require("sdk/ui/button/action");
    10 let button = new ActionButton({
    11   id: "button",
    12   label: "send!",
    13   icon: "./favicon.ico",
    14   onClick: () => {
    15     frame.postMessage({
    16       hello: "content"
    17     });
    18   }
    19 });
    21 let frame = new Frame({
    22     url: "./index.html",
    23     onAttach: () => {
    24       console.log("frame was attached");
    25     },
    26     onReady: () => {
    27       console.log("frame document was loaded");
    28     },
    29     onLoad: () => {
    30       console.log("frame load complete");
    31     },
    32     onMessage: (event) => {
    33       console.log("got message from frame content", event);
    34       if (event.data === "ping!")
    35         event.source.postMessage("pong!", event.source.origin);
    36     }
    37 });
    38 let toolbar = new Toolbar({
    39   items: [frame],
    40   title: "Addon Demo",
    41   hidden: false,
    42   onShow: () => {
    43     console.log("toolbar was shown");
    44   },
    45   onHide: () => {
    46     console.log("toolbar was hidden");
    47   }
    48 });

mercurial