michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0: /* vim: set ts=2 et sw=2 tw=80: */
michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0:
michael@0: let doc;
michael@0: let div;
michael@0: let plate;
michael@0:
michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0: Components.utils.import("resource:///modules/domplate.jsm");
michael@0:
michael@0: function createDocument()
michael@0: {
michael@0: doc.body.innerHTML = '
no
';
michael@0: doc.title = "Domplate Test";
michael@0: setupDomplateTests();
michael@0: }
michael@0:
michael@0: function setupDomplateTests()
michael@0: {
michael@0: ok(domplate, "domplate is defined");
michael@0: plate = domplate({tag: domplate.DIV("Hello!")});
michael@0: ok(plate, "template is defined");
michael@0: div = doc.getElementById("first");
michael@0: ok(div, "we have our div");
michael@0: plate.tag.replace({}, div, template);
michael@0: is(div.innerText, "Hello!", "Is the div's innerText replaced?");
michael@0: finishUp();
michael@0: }
michael@0:
michael@0: function finishUp()
michael@0: {
michael@0: gBrowser.removeCurrentTab();
michael@0: finish();
michael@0: }
michael@0:
michael@0: function test()
michael@0: {
michael@0: waitForExplicitFinish();
michael@0: gBrowser.selectedTab = gBrowser.addTab();
michael@0: gBrowser.selectedBrowser.addEventListener("load", function() {
michael@0: gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0: doc = content.document;
michael@0: waitForFocus(createDocument, content);
michael@0: }, true);
michael@0:
michael@0: content.location = "data:text/html;charset=utf-8,domplate_test.js";
michael@0: }
michael@0: