testing/mochitest/MochiKit/MockDOM.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.

     1 /***
     3 MochiKit.MockDOM 1.4
     5 See <http://mochikit.com/> for documentation, downloads, license, etc.
     7 (c) 2005 Bob Ippolito.  All rights Reserved.
     9 ***/
    11 if (typeof(MochiKit) == "undefined") {
    12     MochiKit = {};
    13 }
    15 if (typeof(MochiKit.MockDOM) == "undefined") {
    16     MochiKit.MockDOM = {};
    17 }
    19 MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
    20 MochiKit.MockDOM.VERSION = "1.4";
    22 MochiKit.MockDOM.__repr__ = function () {
    23     return "[" + this.NAME + " " + this.VERSION + "]";
    24 };
    26 /** @id MochiKit.MockDOM.toString */
    27 MochiKit.MockDOM.toString = function () {
    28     return this.__repr__();
    29 };
    31 /** @id MochiKit.MockDOM.createDocument */
    32 MochiKit.MockDOM.createDocument = function () {
    33     var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
    34     doc.body = doc.createElement("BODY");
    35     doc.appendChild(doc.body);
    36     return doc;
    37 };
    39 /** @id MochiKit.MockDOM.MockElement */
    40 MochiKit.MockDOM.MockElement = function (name, data) {
    41     this.tagName = this.nodeName = name.toUpperCase();
    42     if (typeof(data) == "string") {
    43         this.nodeValue = data;
    44         this.nodeType = 3;
    45     } else {
    46         this.nodeType = 1;
    47         this.childNodes = [];
    48     }
    49     if (name.substring(0, 1) == "<") {
    50         var nameattr = name.substring(
    51             name.indexOf('"') + 1, name.lastIndexOf('"'));
    52         name = name.substring(1, name.indexOf(" "));
    53         this.tagName = this.nodeName = name.toUpperCase();
    54         this.setAttribute("name", nameattr);
    55     }
    56 };
    58 MochiKit.MockDOM.MockElement.prototype = {
    59     /** @id MochiKit.MockDOM.MockElement.prototype.createElement */
    60     createElement: function (tagName) {
    61         return new MochiKit.MockDOM.MockElement(tagName);
    62     },
    63     /** @id MochiKit.MockDOM.MockElement.prototype.createTextNode */
    64     createTextNode: function (text) {
    65         return new MochiKit.MockDOM.MockElement("text", text);
    66     },
    67     /** @id MochiKit.MockDOM.MockElement.prototype.setAttribute */
    68     setAttribute: function (name, value) {
    69         this[name] = value;
    70     },
    71     /** @id MochiKit.MockDOM.MockElement.prototype.getAttribute */
    72     getAttribute: function (name) {
    73         return this[name];
    74     },
    75     /** @id MochiKit.MockDOM.MockElement.prototype.appendChild */
    76     appendChild: function (child) {
    77         this.childNodes.push(child);
    78     },
    79     /** @id MochiKit.MockDOM.MockElement.prototype.toString */
    80     toString: function () {
    81         return "MockElement(" + this.tagName + ")";
    82     }
    83 };
    85     /** @id MochiKit.MockDOM.EXPORT_OK */
    86 MochiKit.MockDOM.EXPORT_OK = [
    87     "mockElement",
    88     "createDocument"
    89 ];
    91     /** @id MochiKit.MockDOM.EXPORT */
    92 MochiKit.MockDOM.EXPORT = [
    93     "document"
    94 ];
    96 MochiKit.MockDOM.__new__ = function () {
    97     this.document = this.createDocument();
    98 };
   100 MochiKit.MockDOM.__new__();

mercurial