addon-sdk/source/test/fixtures/test-page-worker.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/test/fixtures/test-page-worker.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +
     1.9 +// get title directly
    1.10 +self.postMessage(["equal", document.title, "Page Worker test",
    1.11 +            "Correct page title accessed directly"]);
    1.12 +
    1.13 +// get <p> directly
    1.14 +let p = document.getElementById("paragraph");
    1.15 +self.postMessage(["ok", !!p, "<p> can be accessed directly"]);
    1.16 +self.postMessage(["equal", p.firstChild.nodeValue,
    1.17 +            "Lorem ipsum dolor sit amet.",
    1.18 +            "Correct text node expected"]);
    1.19 +
    1.20 +// Modify page
    1.21 +let div = document.createElement("div");
    1.22 +div.setAttribute("id", "block");
    1.23 +div.appendChild(document.createTextNode("Test text created"));
    1.24 +document.body.appendChild(div);
    1.25 +
    1.26 +// Check back the modification
    1.27 +div = document.getElementById("block");
    1.28 +self.postMessage(["ok", !!div, "<div> can be accessed directly"]);
    1.29 +self.postMessage(["equal", div.firstChild.nodeValue,
    1.30 +            "Test text created", "Correct text node expected"]);
    1.31 +self.postMessage(["done"]);
    1.32 +

mercurial