browser/base/content/test/general/domplate_test.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 let doc;
michael@0 8 let div;
michael@0 9 let plate;
michael@0 10
michael@0 11 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 12 Components.utils.import("resource:///modules/domplate.jsm");
michael@0 13
michael@0 14 function createDocument()
michael@0 15 {
michael@0 16 doc.body.innerHTML = '<div id="first">no</div>';
michael@0 17 doc.title = "Domplate Test";
michael@0 18 setupDomplateTests();
michael@0 19 }
michael@0 20
michael@0 21 function setupDomplateTests()
michael@0 22 {
michael@0 23 ok(domplate, "domplate is defined");
michael@0 24 plate = domplate({tag: domplate.DIV("Hello!")});
michael@0 25 ok(plate, "template is defined");
michael@0 26 div = doc.getElementById("first");
michael@0 27 ok(div, "we have our div");
michael@0 28 plate.tag.replace({}, div, template);
michael@0 29 is(div.innerText, "Hello!", "Is the div's innerText replaced?");
michael@0 30 finishUp();
michael@0 31 }
michael@0 32
michael@0 33 function finishUp()
michael@0 34 {
michael@0 35 gBrowser.removeCurrentTab();
michael@0 36 finish();
michael@0 37 }
michael@0 38
michael@0 39 function test()
michael@0 40 {
michael@0 41 waitForExplicitFinish();
michael@0 42 gBrowser.selectedTab = gBrowser.addTab();
michael@0 43 gBrowser.selectedBrowser.addEventListener("load", function() {
michael@0 44 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 45 doc = content.document;
michael@0 46 waitForFocus(createDocument, content);
michael@0 47 }, true);
michael@0 48
michael@0 49 content.location = "data:text/html;charset=utf-8,domplate_test.js";
michael@0 50 }
michael@0 51

mercurial