deleted file mode 100644
--- a/toolkit/components/microformats/Microformats.js
+++ /dev/null
@@ -1,1859 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-this.EXPORTED_SYMBOLS = ["Microformats", "adr", "tag", "hCard", "hCalendar", "geo"];
-
-this.Microformats = {
- /* When a microformat is added, the name is placed in this list */
- list: [],
- /* Custom iterator so that microformats can be enumerated as */
- /* for (i in Microformats) */
- __iterator__: function* () {
- for (let i=0; i < this.list.length; i++) {
- yield this.list[i];
- }
- },
- /**
- * Retrieves microformats objects of the given type from a document
- *
- * @param name The name of the microformat (required)
- * @param rootElement The DOM element at which to start searching (required)
- * @param options Literal object with the following options:
- * recurseExternalFrames - Whether or not to search child frames
- * that reference external pages (with a src attribute)
- * for microformats (optional - defaults to true)
- * showHidden - Whether or not to add hidden microformat
- * (optional - defaults to false)
- * debug - Whether or not we are in debug mode (optional
- * - defaults to false)
- * @param targetArray An array of microformat objects to which is added the results (optional)
- * @return A new array of microformat objects or the passed in microformat
- * object array with the new objects added
- */
- get: function(name, rootElement, options, targetArray) {
- function isAncestor(haystack, needle) {
- var parent = needle;
- while (parent = parent.parentNode) {
- /* We need to check parentNode because defaultView.frames[i].frameElement */
- /* isn't a real DOM node */
- if (parent == needle.parentNode) {
- return true;
- }
- }
- return false;
- }
- if (!Microformats[name] || !rootElement) {
- return undefined;
- }
- targetArray = targetArray || [];
-
- /* Root element might not be the document - we need the document's default view */
- /* to get frames and to check their ancestry */
- var defaultView = rootElement.defaultView || rootElement.ownerDocument.defaultView;
- var rootDocument = rootElement.ownerDocument || rootElement;
-
- /* If recurseExternalFrames is undefined or true, look through all child frames for microformats */
- if (!options || !options.hasOwnProperty("recurseExternalFrames") || options.recurseExternalFrames) {
- if (defaultView && defaultView.frames.length > 0) {
- for (let i=0; i < defaultView.frames.length; i++) {
- if (isAncestor(rootDocument, defaultView.frames[i].frameElement)) {
- Microformats.get(name, defaultView.frames[i].document, options, targetArray);
- }
- }
- }
- }
-
- /* Get the microformat nodes for the document */
- var microformatNodes = [];
- if (Microformats[name].className) {
- microformatNodes = Microformats.getElementsByClassName(rootElement,
- Microformats[name].className);
- /* alternateClassName is for cases where a parent microformat is inferred by the children */
- /* If we find alternateClassName, the entire document becomes the microformat */
- if ((microformatNodes.length == 0) && Microformats[name].alternateClassName) {
- var altClass = Microformats.getElementsByClassName(rootElement, Microformats[name].alternateClassName);
- if (altClass.length > 0) {
- microformatNodes.push(rootElement);
- }
- }
- } else if (Microformats[name].attributeValues) {
- microformatNodes =
- Microformats.getElementsByAttribute(rootElement,
- Microformats[name].attributeName,
- Microformats[name].attributeValues);
-
- }
-
-
- function isVisible(node, checkChildren) {
- if (node.getBoundingClientRect) {
- var box = node.getBoundingClientRect();
- } else {
- box = node.ownerDocument.getBoxObjectFor(node);
- }
- /* If the parent has is an empty box, double check the children */
- if ((box.height == 0) || (box.width == 0)) {
- if (checkChildren && node.childNodes.length > 0) {
- for(let i=0; i < node.childNodes.length; i++) {
- if (node.childNodes[i].nodeType == Components.interfaces.nsIDOMNode.ELEMENT_NODE) {
- /* For performance reasons, we only go down one level */
- /* of children */
- if (isVisible(node.childNodes[i], false)) {
- return true;
- }
- }
- }
- }
- return false
- }
- return true;
- }
-
- /* Create objects for the microformat nodes and put them into the microformats */
- /* array */
- for (let i = 0; i < microformatNodes.length; i++) {
- /* If showHidden undefined or false, don't add microformats to the list that aren't visible */
- if (!options || !options.hasOwnProperty("showHidden") || !options.showHidden) {
- if (microformatNodes[i].ownerDocument) {
- if (!isVisible(microformatNodes[i], true)) {
- continue;
- }
- }
- }
- try {
- if (options && options.debug) {
- /* Don't validate in the debug case so that we don't get errors thrown */
- /* in the debug case, we want all microformats, even if they are invalid */
- targetArray.push(new Microformats[name].mfObject(microformatNodes[i], false));
- } else {
- targetArray.push(new Microformats[name].mfObject(microformatNodes[i], true));
- }
- } catch (ex) {
- /* Creation of individual object probably failed because it is invalid. */
- /* This isn't a problem, because the page might have invalid microformats */
- }
- }
- return targetArray;
- },
- /**
- * Counts microformats objects of the given type from a document
- *
- * @param name The name of the microformat (required)
- * @param rootElement The DOM element at which to start searching (required)
- * @param options Literal object with the following options:
- * recurseExternalFrames - Whether or not to search child frames
- * that reference external pages (with a src attribute)
- * for microformats (optional - defaults to true)
- * showHidden - Whether or not to add hidden microformat
- * (optional - defaults to false)
- * debug - Whether or not we are in debug mode (optional
- * - defaults to false)
- * @return The new count
- */
- count: function(name, rootElement, options) {
- var mfArray = Microformats.get(name, rootElement, options);
- if (mfArray) {
- return mfArray.length;
- }
- return 0;
- },
- /**
- * Returns true if the passed in node is a microformat. Does NOT return true
- * if the passed in node is a child of a microformat.
- *
- * @param node DOM node to check
- * @return true if the node is a microformat, false if it is not
- */
- isMicroformat: function(node) {
- for (let i in Microformats)
- {
- if (Microformats[i].className) {
- if (Microformats.matchClass(node, Microformats[i].className)) {
- return true;
- }
- } else {
- var attribute;
- if (attribute = node.getAttribute(Microformats[i].attributeName)) {
- var attributeList = Microformats[i].attributeValues.split(" ");
- for (let j=0; j < attributeList.length; j++) {
- if (attribute.match("(^|\\s)" + attributeList[j] + "(\\s|$)")) {
- return true;
- }
- }
- }
- }
- }
- return false;
- },
- /**
- * This function searches a given nodes ancestors looking for a microformat
- * and if it finds it, returns it. It does NOT include self, so if the passed
- * in node is a microformat, it will still search ancestors for a microformat.
- *
- * @param node DOM node to check
- * @return If the node is contained in a microformat, it returns the parent
- * DOM node, otherwise returns null
- */
- getParent: function(node) {
- var xpathExpression;
- var xpathResult;
-
- xpathExpression = "ancestor::*[";
- for (let i=0; i < Microformats.list.length; i++) {
- var mfname = Microformats.list[i];
- if (i != 0) {
- xpathExpression += " or ";
- }
- if (Microformats[mfname].className) {
- xpathExpression += "contains(concat(' ', @class, ' '), ' " + Microformats[mfname].className + " ')";
- } else {
- var attributeList = Microformats[mfname].attributeValues.split(" ");
- for (let j=0; j < attributeList.length; j++) {
- if (j != 0) {
- xpathExpression += " or ";
- }
- xpathExpression += "contains(concat(' ', @" + Microformats[mfname].attributeName + ", ' '), ' " + attributeList[j] + " ')";
- }
- }
- }
- xpathExpression += "][1]";
- xpathResult = (node.ownerDocument || node).evaluate(xpathExpression, node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, null);
- if (xpathResult.singleNodeValue) {
- xpathResult.singleNodeValue.microformat = mfname;
- return xpathResult.singleNodeValue;
- }
- return null;
- },
- /**
- * If the passed in node is a microformat, this function returns a space
- * separated list of the microformat names that correspond to this node
- *
- * @param node DOM node to check
- * @return If the node is a microformat, a space separated list of microformat
- * names, otherwise returns nothing
- */
- getNamesFromNode: function(node) {
- var microformatNames = [];
- var xpathExpression;
- var xpathResult;
- for (let i in Microformats)
- {
- if (Microformats[i]) {
- if (Microformats[i].className) {
- if (Microformats.matchClass(node, Microformats[i].className)) {
- microformatNames.push(i);
- continue;
- }
- } else if (Microformats[i].attributeValues) {
- var attribute;
- if (attribute = node.getAttribute(Microformats[i].attributeName)) {
- var attributeList = Microformats[i].attributeValues.split(" ");
- for (let j=0; j < attributeList.length; j++) {
- /* If we match any attribute, we've got a microformat */
- if (attribute.match("(^|\\s)" + attributeList[j] + "(\\s|$)")) {
- microformatNames.push(i);
- break;
- }
- }
- }
- }
- }
- }
- return microformatNames.join(" ");
- },
- /**
- * Outputs the contents of a microformat object for debug purposes.
- *
- * @param microformatObject JavaScript object that represents a microformat
- * @return string containing a visual representation of the contents of the microformat
- */
- debug: function debug(microformatObject) {
- function dumpObject(item, indent)
- {
- if (!indent) {
- indent = "";
- }
- var toreturn = "";
- var testArray = [];
-
- for (let i in item)
- {
- if (testArray[i]) {
- continue;
- }
- if (typeof item[i] == "object") {
- if ((i != "node") && (i != "resolvedNode")) {
- if (item[i] && item[i].semanticType) {
- toreturn += indent + item[i].semanticType + " [" + i + "] { \n";
- } else {
- toreturn += indent + "object " + i + " { \n";
- }
- toreturn += dumpObject(item[i], indent + "\t");
- toreturn += indent + "}\n";
- }
- } else if ((typeof item[i] != "function") && (i != "semanticType")) {
- if (item[i]) {
- toreturn += indent + i + "=" + item[i] + "\n";
- }
- }
- }
- if (!toreturn && item) {
- toreturn = item.toString();
- }
- return toreturn;
- }
- return dumpObject(microformatObject);
- },
- add: function add(microformat, microformatDefinition) {
- /* We always replace an existing definition with the new one */
- if (!Microformats[microformat]) {
- Microformats.list.push(microformat);
- }
- Microformats[microformat] = microformatDefinition;
- microformatDefinition.mfObject.prototype.debug =
- function(microformatObject) {
- return Microformats.debug(microformatObject)
- };
- },
- remove: function remove(microformat) {
- if (Microformats[microformat]) {
- var list = Microformats.list;
- var index = list.indexOf(microformat, 1);
- if (index != -1) {
- list.splice(index, 1);
- }
- delete Microformats[microformat];
- }
- },
- /* All parser specific functions are contained in this object */
- parser: {
- /**
- * Uses the microformat patterns to decide what the correct text for a
- * given microformat property is. This includes looking at things like
- * abbr, img/alt, area/alt and value excerpting.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- & @param datatype HTML/text - whether to use innerHTML or innerText - defaults to text
- * @return A string with the value of the property
- */
- defaultGetter: function(propnode, parentnode, datatype) {
- function collapseWhitespace(instring) {
- /* Remove new lines, carriage returns and tabs */
- outstring = instring.replace(/[\n\r\t]/gi, ' ');
- /* Replace any double spaces with single spaces */
- outstring = outstring.replace(/\s{2,}/gi, ' ');
- /* Remove any double spaces that are left */
- outstring = outstring.replace(/\s{2,}/gi, '');
- /* Remove any spaces at the beginning */
- outstring = outstring.replace(/^\s+/, '');
- /* Remove any spaces at the end */
- outstring = outstring.replace(/\s+$/, '');
- return outstring;
- }
-
-
- if (((((propnode.localName.toLowerCase() == "abbr") || (propnode.localName.toLowerCase() == "html:abbr")) && !propnode.namespaceURI) ||
- ((propnode.localName.toLowerCase() == "abbr") && (propnode.namespaceURI == "http://www.w3.org/1999/xhtml"))) && (propnode.hasAttribute("title"))) {
- return propnode.getAttribute("title");
- } else if ((propnode.nodeName.toLowerCase() == "img") && (propnode.hasAttribute("alt"))) {
- return propnode.getAttribute("alt");
- } else if ((propnode.nodeName.toLowerCase() == "area") && (propnode.hasAttribute("alt"))) {
- return propnode.getAttribute("alt");
- } else if ((propnode.nodeName.toLowerCase() == "textarea") ||
- (propnode.nodeName.toLowerCase() == "select") ||
- (propnode.nodeName.toLowerCase() == "input")) {
- return propnode.value;
- } else {
- var values = Microformats.getElementsByClassName(propnode, "value");
- /* Verify that values are children of the propnode */
- for (let i = values.length-1; i >= 0; i--) {
- if (values[i].parentNode != propnode) {
- values.splice(i,1);
- }
- }
- if (values.length > 0) {
- var value = "";
- for (let j=0;j<values.length;j++) {
- value += Microformats.parser.defaultGetter(values[j], propnode, datatype);
- }
- return collapseWhitespace(value);
- }
- var s;
- if (datatype == "HTML") {
- s = propnode.innerHTML;
- } else {
- if (propnode.innerText) {
- s = propnode.innerText;
- } else {
- s = propnode.textContent;
- }
- }
- /* If we are processing a value node, don't remove whitespace now */
- /* (we'll do it later) */
- if (!Microformats.matchClass(propnode, "value")) {
- s = collapseWhitespace(s);
- }
- if (s.length > 0) {
- return s;
- }
- }
- return undefined;
- },
- /**
- * Used to specifically retrieve a date in a microformat node.
- * After getting the default text, it normalizes it to an ISO8601 date.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with the normalized date.
- */
- dateTimeGetter: function(propnode, parentnode) {
- var date = Microformats.parser.textGetter(propnode, parentnode);
- if (date) {
- return Microformats.parser.normalizeISO8601(date);
- }
- return undefined;
- },
- /**
- * Used to specifically retrieve a URI in a microformat node. This includes
- * looking at an href/img/object/area to get the fully qualified URI.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with the fully qualified URI.
- */
- uriGetter: function(propnode, parentnode) {
- var pairs = {"a":"href", "img":"src", "object":"data", "area":"href"};
- var name = propnode.nodeName.toLowerCase();
- if (pairs.hasOwnProperty(name)) {
- return propnode[pairs[name]];
- }
- return Microformats.parser.textGetter(propnode, parentnode);
- },
- /**
- * Used to specifically retrieve a telephone number in a microformat node.
- * Basically this is to handle the face that telephone numbers use value
- * as the name as one of their subproperties, but value is also used for
- * value excerpting (http://microformats.org/wiki/hcard#Value_excerpting)
-
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with the telephone number
- */
- telGetter: function(propnode, parentnode) {
- var pairs = {"a":"href", "object":"data", "area":"href"};
- var name = propnode.nodeName.toLowerCase();
- if (pairs.hasOwnProperty(name)) {
- var protocol;
- if (propnode[pairs[name]].indexOf("tel:") == 0) {
- protocol = "tel:";
- }
- if (propnode[pairs[name]].indexOf("fax:") == 0) {
- protocol = "fax:";
- }
- if (propnode[pairs[name]].indexOf("modem:") == 0) {
- protocol = "modem:";
- }
- if (protocol) {
- if (propnode[pairs[name]].indexOf('?') > 0) {
- return unescape(propnode[pairs[name]].substring(protocol.length, propnode[pairs[name]].indexOf('?')));
- } else {
- return unescape(propnode[pairs[name]].substring(protocol.length));
- }
- }
- }
- /* Special case - if this node is a value, use the parent node to get all the values */
- if (Microformats.matchClass(propnode, "value")) {
- return Microformats.parser.textGetter(parentnode, parentnode);
- } else {
- /* Virtual case */
- if (!parentnode && (Microformats.getElementsByClassName(propnode, "type").length > 0)) {
- var tempNode = propnode.cloneNode(true);
- var typeNodes = Microformats.getElementsByClassName(tempNode, "type");
- for (let i=0; i < typeNodes.length; i++) {
- typeNodes[i].parentNode.removeChild(typeNodes[i]);
- }
- return Microformats.parser.textGetter(tempNode);
- }
- return Microformats.parser.textGetter(propnode, parentnode);
- }
- },
- /**
- * Used to specifically retrieve an email address in a microformat node.
- * This includes at an href, as well as removing subject if specified and
- * the mailto prefix.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with the email address.
- */
- emailGetter: function(propnode, parentnode) {
- if ((propnode.nodeName.toLowerCase() == "a") || (propnode.nodeName.toLowerCase() == "area")) {
- var mailto = propnode.href;
- /* IO Service won't fully parse mailto, so we do it manually */
- if (mailto.indexOf('?') > 0) {
- return unescape(mailto.substring("mailto:".length, mailto.indexOf('?')));
- } else {
- return unescape(mailto.substring("mailto:".length));
- }
- } else {
- /* Special case - if this node is a value, use the parent node to get all the values */
- /* If this case gets executed, per the value design pattern, the result */
- /* will be the EXACT email address with no extra parsing required */
- if (Microformats.matchClass(propnode, "value")) {
- return Microformats.parser.textGetter(parentnode, parentnode);
- } else {
- /* Virtual case */
- if (!parentnode && (Microformats.getElementsByClassName(propnode, "type").length > 0)) {
- var tempNode = propnode.cloneNode(true);
- var typeNodes = Microformats.getElementsByClassName(tempNode, "type");
- for (let i=0; i < typeNodes.length; i++) {
- typeNodes[i].parentNode.removeChild(typeNodes[i]);
- }
- return Microformats.parser.textGetter(tempNode);
- }
- return Microformats.parser.textGetter(propnode, parentnode);
- }
- }
- },
- /**
- * Used when a caller needs the text inside a particular DOM node.
- * It calls defaultGetter to handle all the subtleties of getting
- * text from a microformat.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with just the text including all tags.
- */
- textGetter: function(propnode, parentnode) {
- return Microformats.parser.defaultGetter(propnode, parentnode, "text");
- },
- /**
- * Used when a caller needs the HTML inside a particular DOM node.
- *
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return An emulated string object that also has a new function called toHTML
- */
- HTMLGetter: function(propnode, parentnode) {
- /* This is so we can have a string that behaves like a string */
- /* but also has a new function that can return the HTML that corresponds */
- /* to the string. */
- function mfHTML(value) {
- this.valueOf = function() {return value ? value.valueOf() : "";}
- this.toString = function() {return value ? value.toString() : "";}
- }
- mfHTML.prototype = new String;
- mfHTML.prototype.toHTML = function() {
- return Microformats.parser.defaultGetter(propnode, parentnode, "HTML");
- }
- return new mfHTML(Microformats.parser.defaultGetter(propnode, parentnode, "text"));
- },
- /**
- * Internal parser API used to determine which getter to call based on the
- * datatype specified in the microformat definition.
- *
- * @param prop The microformat property in the definition
- * @param propnode The DOMNode to check
- * @param parentnode The parent node of the property. If it is a subproperty,
- * this is the parent property node. If it is not, this is the
- * microformat node.
- * @return A string with the property value.
- */
- datatypeHelper: function(prop, node, parentnode) {
- var result;
- var datatype = prop.datatype;
- switch (datatype) {
- case "dateTime":
- result = Microformats.parser.dateTimeGetter(node, parentnode);
- break;
- case "anyURI":
- result = Microformats.parser.uriGetter(node, parentnode);
- break;
- case "email":
- result = Microformats.parser.emailGetter(node, parentnode);
- break;
- case "tel":
- result = Microformats.parser.telGetter(node, parentnode);
- break;
- case "HTML":
- result = Microformats.parser.HTMLGetter(node, parentnode);
- break;
- case "float":
- var asText = Microformats.parser.textGetter(node, parentnode);
- if (!isNaN(asText)) {
- result = parseFloat(asText);
- }
- break;
- case "custom":
- result = prop.customGetter(node, parentnode);
- break;
- case "microformat":
- try {
- result = new Microformats[prop.microformat].mfObject(node, true);
- } catch (ex) {
- /* There are two reasons we get here, one because the node is not */
- /* a microformat and two because the node is a microformat and */
- /* creation failed. If the node is not a microformat, we just fall */
- /* through and use the default getter since there are some cases */
- /* (location in hCalendar) where a property can be either a microformat */
- /* or a string. If creation failed, we break and simply don't add the */
- /* microformat property to the parent microformat */
- if (ex != "Node is not a microformat (" + prop.microformat + ")") {
- break;
- }
- }
- if (result != undefined) {
- if (prop.microformat_property) {
- result = result[prop.microformat_property];
- }
- break;
- }
- default:
- result = Microformats.parser.textGetter(node, parentnode);
- break;
- }
- /* This handles the case where one property implies another property */
- /* For instance, org by itself is actually org.organization-name */
- if (prop.values && (result != undefined)) {
- var validType = false;
- for (let value in prop.values) {
- if (result.toLowerCase() == prop.values[value]) {
- result = result.toLowerCase();
- validType = true;
- break;
- }
- }
- if (!validType) {
- return undefined;
- }
- }
- return result;
- },
- newMicroformat: function(object, in_node, microformat, validate) {
- /* check to see if we are even valid */
- if (!Microformats[microformat]) {
- throw("Invalid microformat - " + microformat);
- }
- if (in_node.ownerDocument) {
- if (Microformats[microformat].attributeName) {
- if (!(in_node.hasAttribute(Microformats[microformat].attributeName))) {
- throw("Node is not a microformat (" + microformat + ")");
- }
- } else {
- if (!Microformats.matchClass(in_node, Microformats[microformat].className)) {
- throw("Node is not a microformat (" + microformat + ")");
- }
- }
- }
- var node = in_node;
- if ((Microformats[microformat].className) && in_node.ownerDocument) {
- node = Microformats.parser.preProcessMicroformat(in_node);
- }
-
- for (let i in Microformats[microformat].properties) {
- object.__defineGetter__(i, Microformats.parser.getMicroformatPropertyGenerator(node, microformat, i, object));
- }
-
- /* The node in the object should be the original node */
- object.node = in_node;
- /* we also store the node that has been "resolved" */
- object.resolvedNode = node;
- object.semanticType = microformat;
- if (validate) {
- Microformats.parser.validate(node, microformat);
- }
- },
- getMicroformatPropertyGenerator: function getMicroformatPropertyGenerator(node, name, property, microformat)
- {
- return function() {
- var result = Microformats.parser.getMicroformatProperty(node, name, property);
-// delete microformat[property];
-// microformat[property] = result;
- return result;
- };
- },
- getPropertyInternal: function getPropertyInternal(propnode, parentnode, propobj, propname, mfnode) {
- var result;
- if (propobj.subproperties) {
- for (let subpropname in propobj.subproperties) {
- var subpropnodes;
- var subpropobj = propobj.subproperties[subpropname];
- if (subpropobj.rel == true) {
- subpropnodes = Microformats.getElementsByAttribute(propnode, "rel", subpropname);
- } else {
- subpropnodes = Microformats.getElementsByClassName(propnode, subpropname);
- }
- var resultArray = [];
- var subresult;
- for (let i = 0; i < subpropnodes.length; i++) {
- subresult = Microformats.parser.getPropertyInternal(subpropnodes[i], propnode,
- subpropobj,
- subpropname, mfnode);
- if (subresult != undefined) {
- resultArray.push(subresult);
- /* If we're not a plural property, don't bother getting more */
- if (!subpropobj.plural) {
- break;
- }
- }
- }
- if (resultArray.length == 0) {
- subresult = Microformats.parser.getPropertyInternal(propnode, null,
- subpropobj,
- subpropname, mfnode);
- if (subresult != undefined) {
- resultArray.push(subresult);
- }
- }
- if (resultArray.length > 0) {
- result = result || {};
- if (subpropobj.plural) {
- result[subpropname] = resultArray;
- } else {
- result[subpropname] = resultArray[0];
- }
- }
- }
- }
- if (!parentnode || (!result && propobj.subproperties)) {
- if (propobj.virtual) {
- if (propobj.virtualGetter) {
- result = propobj.virtualGetter(mfnode || propnode);
- } else {
- result = Microformats.parser.datatypeHelper(propobj, propnode);
- }
- }
- } else if (!result) {
- result = Microformats.parser.datatypeHelper(propobj, propnode, parentnode);
- }
- return result;
- },
- getMicroformatProperty: function getMicroformatProperty(in_mfnode, mfname, propname) {
- var mfnode = in_mfnode;
- /* If the node has not been preprocessed, the requested microformat */
- /* is a class based microformat and the passed in node is not the */
- /* entire document, preprocess it. Preprocessing the node involves */
- /* creating a duplicate of the node and taking care of things like */
- /* the include and header design patterns */
- if (!in_mfnode.origNode && Microformats[mfname].className && in_mfnode.ownerDocument) {
- mfnode = Microformats.parser.preProcessMicroformat(in_mfnode);
- }
- /* propobj is the corresponding property object in the microformat */
- var propobj;
- /* If there is a corresponding property in the microformat, use it */
- if (Microformats[mfname].properties[propname]) {
- propobj = Microformats[mfname].properties[propname];
- } else {
- /* If we didn't get a property, bail */
- return undefined;
- }
- /* Query the correct set of nodes (rel or class) based on the setting */
- /* in the property */
- var propnodes;
- if (propobj.rel == true) {
- propnodes = Microformats.getElementsByAttribute(mfnode, "rel", propname);
- } else {
- propnodes = Microformats.getElementsByClassName(mfnode, propname);
- }
- for (let i=propnodes.length-1; i >= 0; i--) {
- /* The reason getParent is not used here is because this code does */
- /* not apply to attribute based microformats, plus adr and geo */
- /* when contained in hCard are a special case */
- var parentnode;
- var node = propnodes[i];
- var xpathExpression = "";
- for (let j=0; j < Microformats.list.length; j++) {
- /* Don't treat adr or geo in an hCard as a microformat in this case */
- if ((mfname == "hCard") && ((Microformats.list[j] == "adr") || (Microformats.list[j] == "geo"))) {
- continue;
- }
- if (Microformats[Microformats.list[j]].className) {
- if (xpathExpression.length == 0) {
- xpathExpression = "ancestor::*[";
- } else {
- xpathExpression += " or ";
- }
- xpathExpression += "contains(concat(' ', @class, ' '), ' " + Microformats[Microformats.list[j]].className + " ')";
- }
- }
- xpathExpression += "][1]";
- var xpathResult = (node.ownerDocument || node).evaluate(xpathExpression, node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, null);
- if (xpathResult.singleNodeValue) {
- xpathResult.singleNodeValue.microformat = mfname;
- parentnode = xpathResult.singleNodeValue;
- }
- /* If the propnode is not a child of the microformat, and */
- /* the property belongs to the parent microformat as well, */
- /* remove it. */
- if (parentnode != mfnode) {
- var mfNameString = Microformats.getNamesFromNode(parentnode);
- var mfNames = mfNameString.split(" ");
- var j;
- for (j=0; j < mfNames.length; j++) {
- /* If this property is in the parent microformat, remove the node */
- if (Microformats[mfNames[j]].properties[propname]) {
- propnodes.splice(i,1);
- break;
- }
- }
- }
- }
- if (propnodes.length > 0) {
- var resultArray = [];
- for (let i = 0; i < propnodes.length; i++) {
- var subresult = Microformats.parser.getPropertyInternal(propnodes[i],
- mfnode,
- propobj,
- propname);
- if (subresult != undefined) {
- resultArray.push(subresult);
- /* If we're not a plural property, don't bother getting more */
- if (!propobj.plural) {
- return resultArray[0];
- }
- }
- }
- if (resultArray.length > 0) {
- return resultArray;
- }
- } else {
- /* If we didn't find any class nodes, check to see if this property */
- /* is virtual and if so, call getPropertyInternal again */
- if (propobj.virtual) {
- return Microformats.parser.getPropertyInternal(mfnode, null,
- propobj, propname);
- }
- }
- return undefined;
- },
- /**
- * Internal parser API used to resolve includes and headers. Includes are
- * resolved by simply cloning the node and replacing it in a clone of the
- * original DOM node. Headers are resolved by creating a span and then copying
- * the innerHTML and the class name.
- *
- * @param in_mfnode The node to preProcess.
- * @return If the node had includes or headers, a cloned node otherwise
- * the original node. You can check to see if the node was cloned
- * by looking for .origNode in the new node.
- */
- preProcessMicroformat: function preProcessMicroformat(in_mfnode) {
- var mfnode;
- if ((in_mfnode.nodeName.toLowerCase() == "td") && (in_mfnode.hasAttribute("headers"))) {
- mfnode = in_mfnode.cloneNode(true);
- mfnode.origNode = in_mfnode;
- var headers = in_mfnode.getAttribute("headers").split(" ");
- for (let i = 0; i < headers.length; i++) {
- var tempNode = in_mfnode.ownerDocument.createElement("span");
- var headerNode = in_mfnode.ownerDocument.getElementById(headers[i]);
- if (headerNode) {
- tempNode.innerHTML = headerNode.innerHTML;
- tempNode.className = headerNode.className;
- mfnode.appendChild(tempNode);
- }
- }
- } else {
- mfnode = in_mfnode;
- }
- var includes = Microformats.getElementsByClassName(mfnode, "include");
- if (includes.length > 0) {
- /* If we didn't clone, clone now */
- if (!mfnode.origNode) {
- mfnode = in_mfnode.cloneNode(true);
- mfnode.origNode = in_mfnode;
- }
- includes = Microformats.getElementsByClassName(mfnode, "include");
- var includeId;
- var include_length = includes.length;
- for (let i = include_length -1; i >= 0; i--) {
- if (includes[i].nodeName.toLowerCase() == "a") {
- includeId = includes[i].getAttribute("href").substr(1);
- }
- if (includes[i].nodeName.toLowerCase() == "object") {
- includeId = includes[i].getAttribute("data").substr(1);
- }
- if (in_mfnode.ownerDocument.getElementById(includeId)) {
- includes[i].parentNode.replaceChild(in_mfnode.ownerDocument.getElementById(includeId).cloneNode(true), includes[i]);
- }
- }
- }
- return mfnode;
- },
- validate: function validate(mfnode, mfname) {
- var error = "";
- if (Microformats[mfname].validate) {
- return Microformats[mfname].validate(mfnode);
- } else if (Microformats[mfname].required) {
- for (let i=0;i<Microformats[mfname].required.length;i++) {
- if (!Microformats.parser.getMicroformatProperty(mfnode, mfname, Microformats[mfname].required[i])) {
- error += "Required property " + Microformats[mfname].required[i] + " not specified\n";
- }
- }
- if (error.length > 0) {
- throw(error);
- }
- return true;
- }
- return undefined;
- },
- /* This function normalizes an ISO8601 date by adding punctuation and */
- /* ensuring that hours and seconds have values */
- normalizeISO8601: function normalizeISO8601(string)
- {
- var dateArray = string.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:([-+Z])(?:(\d\d)(?::?(\d\d))?)?)?)?)?)?/);
-
- var dateString;
- var tzOffset = 0;
- if (!dateArray) {
- return undefined;
- }
- if (dateArray[1]) {
- dateString = dateArray[1];
- if (dateArray[2]) {
- dateString += "-" + dateArray[2];
- if (dateArray[3]) {
- dateString += "-" + dateArray[3];
- if (dateArray[4]) {
- dateString += "T" + dateArray[4];
- if (dateArray[5]) {
- dateString += ":" + dateArray[5];
- } else {
- dateString += ":" + "00";
- }
- if (dateArray[6]) {
- dateString += ":" + dateArray[6];
- } else {
- dateString += ":" + "00";
- }
- if (dateArray[7]) {
- dateString += "." + dateArray[7];
- }
- if (dateArray[8]) {
- dateString += dateArray[8];
- if ((dateArray[8] == "+") || (dateArray[8] == "-")) {
- if (dateArray[9]) {
- dateString += dateArray[9];
- if (dateArray[10]) {
- dateString += dateArray[10];
- }
- }
- }
- }
- }
- }
- }
- }
- return dateString;
- }
- },
- /**
- * Converts an ISO8601 date into a JavaScript date object, honoring the TZ
- * offset and Z if present to convert the date to local time
- * NOTE: I'm using an extra parameter on the date object for this function.
- * I set date.time to true if there is a date, otherwise date.time is false.
- *
- * @param string ISO8601 formatted date
- * @return JavaScript date object that represents the ISO date.
- */
- dateFromISO8601: function dateFromISO8601(string) {
- var dateArray = string.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:([-+Z])(?:(\d\d)(?::?(\d\d))?)?)?)?)?)?/);
-
- var date = new Date(dateArray[1], 0, 1);
- date.time = false;
-
- if (dateArray[2]) {
- date.setMonth(dateArray[2] - 1);
- }
- if (dateArray[3]) {
- date.setDate(dateArray[3]);
- }
- if (dateArray[4]) {
- date.setHours(dateArray[4]);
- date.time = true;
- if (dateArray[5]) {
- date.setMinutes(dateArray[5]);
- if (dateArray[6]) {
- date.setSeconds(dateArray[6]);
- if (dateArray[7]) {
- date.setMilliseconds(Number("0." + dateArray[7]) * 1000);
- }
- }
- }
- }
- if (dateArray[8]) {
- if (dateArray[8] == "-") {
- if (dateArray[9] && dateArray[10]) {
- date.setHours(date.getHours() + parseInt(dateArray[9], 10));
- date.setMinutes(date.getMinutes() + parseInt(dateArray[10], 10));
- }
- } else if (dateArray[8] == "+") {
- if (dateArray[9] && dateArray[10]) {
- date.setHours(date.getHours() - parseInt(dateArray[9], 10));
- date.setMinutes(date.getMinutes() - parseInt(dateArray[10], 10));
- }
- }
- /* at this point we have the time in gmt */
- /* convert to local if we had a Z - or + */
- if (dateArray[8]) {
- var tzOffset = date.getTimezoneOffset();
- if (tzOffset < 0) {
- date.setMinutes(date.getMinutes() + tzOffset);
- } else if (tzOffset > 0) {
- date.setMinutes(date.getMinutes() - tzOffset);
- }
- }
- }
- return date;
- },
- /**
- * Converts a Javascript date object into an ISO 8601 formatted date
- * NOTE: I'm using an extra parameter on the date object for this function.
- * If date.time is NOT true, this function only outputs the date.
- *
- * @param date Javascript Date object
- * @param punctuation true if the date should have -/:
- * @return string with the ISO date.
- */
- iso8601FromDate: function iso8601FromDate(date, punctuation) {
- var string = date.getFullYear().toString();
- if (punctuation) {
- string += "-";
- }
- string += (date.getMonth() + 1).toString().replace(/\b(\d)\b/g, '0$1');
- if (punctuation) {
- string += "-";
- }
- string += date.getDate().toString().replace(/\b(\d)\b/g, '0$1');
- if (date.time) {
- string += "T";
- string += date.getHours().toString().replace(/\b(\d)\b/g, '0$1');
- if (punctuation) {
- string += ":";
- }
- string += date.getMinutes().toString().replace(/\b(\d)\b/g, '0$1');
- if (punctuation) {
- string += ":";
- }
- string += date.getSeconds().toString().replace(/\b(\d)\b/g, '0$1');
- if (date.getMilliseconds() > 0) {
- if (punctuation) {
- string += ".";
- }
- string += date.getMilliseconds().toString();
- }
- }
- return string;
- },
- simpleEscape: function simpleEscape(s)
- {
- s = s.replace(/\&/g, '%26');
- s = s.replace(/\#/g, '%23');
- s = s.replace(/\+/g, '%2B');
- s = s.replace(/\-/g, '%2D');
- s = s.replace(/\=/g, '%3D');
- s = s.replace(/\'/g, '%27');
- s = s.replace(/\,/g, '%2C');
-// s = s.replace(/\r/g, '%0D');
-// s = s.replace(/\n/g, '%0A');
- s = s.replace(/ /g, '+');
- return s;
- },
- /**
- * Not intended for external consumption. Microformat implementations might use it.
- *
- * Retrieve elements matching all classes listed in a space-separated string.
- * I had to implement my own because I need an Array, not an nsIDomNodeList
- *
- * @param rootElement The DOM element at which to start searching (optional)
- * @param className A space separated list of classenames
- * @return microformatNodes An array of DOM Nodes, each representing a
- microformat in the document.
- */
- getElementsByClassName: function getElementsByClassName(rootNode, className)
- {
- var returnElements = [];
-
- if ((rootNode.ownerDocument || rootNode).getElementsByClassName) {
- /* Firefox 3 - native getElementsByClassName */
- var col = rootNode.getElementsByClassName(className);
- for (let i = 0; i < col.length; i++) {
- returnElements[i] = col[i];
- }
- } else if ((rootNode.ownerDocument || rootNode).evaluate) {
- /* Firefox 2 and below - XPath */
- var xpathExpression;
- xpathExpression = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
- var xpathResult = (rootNode.ownerDocument || rootNode).evaluate(xpathExpression, rootNode, null, 0, null);
-
- var node;
- while (node = xpathResult.iterateNext()) {
- returnElements.push(node);
- }
- } else {
- /* Slow fallback for testing */
- className = className.replace(/\-/g, "\\-");
- var elements = rootNode.getElementsByTagName("*");
- for (let i=0;i<elements.length;i++) {
- if (elements[i].className.match("(^|\\s)" + className + "(\\s|$)")) {
- returnElements.push(elements[i]);
- }
- }
- }
- return returnElements;
- },
- /**
- * Not intended for external consumption. Microformat implementations might use it.
- *
- * Retrieve elements matching an attribute and an attribute list in a space-separated string.
- *
- * @param rootElement The DOM element at which to start searching (optional)
- * @param atributeName The attribute name to match against
- * @param attributeValues A space separated list of attribute values
- * @return microformatNodes An array of DOM Nodes, each representing a
- microformat in the document.
- */
- getElementsByAttribute: function getElementsByAttribute(rootNode, attributeName, attributeValues)
- {
- var attributeList = attributeValues.split(" ");
-
- var returnElements = [];
-
- if ((rootNode.ownerDocument || rootNode).evaluate) {
- /* Firefox 3 and below - XPath */
- /* Create an XPath expression based on the attribute list */
- var xpathExpression = ".//*[";
- for (let i = 0; i < attributeList.length; i++) {
- if (i != 0) {
- xpathExpression += " or ";
- }
- xpathExpression += "contains(concat(' ', @" + attributeName + ", ' '), ' " + attributeList[i] + " ')";
- }
- xpathExpression += "]";
-
- var xpathResult = (rootNode.ownerDocument || rootNode).evaluate(xpathExpression, rootNode, null, 0, null);
-
- var node;
- while (node = xpathResult.iterateNext()) {
- returnElements.push(node);
- }
- } else {
- /* Need Slow fallback for testing */
- }
- return returnElements;
- },
- matchClass: function matchClass(node, className) {
- var classValue = node.getAttribute("class");
- return (classValue && classValue.match("(^|\\s)" + className + "(\\s|$)"));
- }
-};
-
-/* MICROFORMAT DEFINITIONS BEGIN HERE */
-
-this.adr = function adr(node, validate) {
- if (node) {
- Microformats.parser.newMicroformat(this, node, "adr", validate);
- }
-}
-
-adr.prototype.toString = function() {
- var address_text = "";
- var start_parens = false;
- if (this["street-address"]) {
- address_text += this["street-address"][0];
- } else if (this["extended-address"]) {
- address_text += this["extended-address"];
- }
- if (this["locality"]) {
- if (this["street-address"] || this["extended-address"]) {
- address_text += " (";
- start_parens = true;
- }
- address_text += this["locality"];
- }
- if (this["region"]) {
- if ((this["street-address"] || this["extended-address"]) && (!start_parens)) {
- address_text += " (";
- start_parens = true;
- } else if (this["locality"]) {
- address_text += ", ";
- }
- address_text += this["region"];
- }
- if (this["country-name"]) {
- if ((this["street-address"] || this["extended-address"]) && (!start_parens)) {
- address_text += " (";
- start_parens = true;
- address_text += this["country-name"];
- } else if ((!this["locality"]) && (!this["region"])) {
- address_text += this["country-name"];
- } else if (((!this["locality"]) && (this["region"])) || ((this["locality"]) && (!this["region"]))) {
- address_text += ", ";
- address_text += this["country-name"];
- }
- }
- if (start_parens) {
- address_text += ")";
- }
- return address_text;
-}
-
-var adr_definition = {
- mfObject: adr,
- className: "adr",
- properties: {
- "type" : {
- plural: true,
- values: ["work", "home", "pref", "postal", "dom", "intl", "parcel"]
- },
- "post-office-box" : {
- },
- "street-address" : {
- plural: true
- },
- "extended-address" : {
- },
- "locality" : {
- },
- "region" : {
- },
- "postal-code" : {
- },
- "country-name" : {
- }
- },
- validate: function(node) {
- var xpathExpression = "count(descendant::*[" +
- "contains(concat(' ', @class, ' '), ' post-office-box ')" +
- " or contains(concat(' ', @class, ' '), ' street-address ')" +
- " or contains(concat(' ', @class, ' '), ' extended-address ')" +
- " or contains(concat(' ', @class, ' '), ' locality ')" +
- " or contains(concat(' ', @class, ' '), ' region ')" +
- " or contains(concat(' ', @class, ' '), ' postal-code ')" +
- " or contains(concat(' ', @class, ' '), ' country-name')" +
- "])";
- var xpathResult = (node.ownerDocument || node).evaluate(xpathExpression, node, null, Components.interfaces.nsIDOMXPathResult.ANY_TYPE, null).numberValue;
- if (xpathResult == 0) {
- throw("Unable to create microformat");
- }
- return true;
- }
-};
-
-Microformats.add("adr", adr_definition);
-
-this.hCard = function hCard(node, validate) {
- if (node) {
- Microformats.parser.newMicroformat(this, node, "hCard", validate);
- }
-}
-hCard.prototype.toString = function() {
- if (this.resolvedNode) {
- /* If this microformat has an include pattern, put the */
- /* organization-name in parenthesis after the fn to differentiate */
- /* them. */
- var fns = Microformats.getElementsByClassName(this.node, "fn");
- if (fns.length === 0) {
- if (this.fn) {
- if (this.org && this.org[0]["organization-name"] && (this.fn != this.org[0]["organization-name"])) {
- return this.fn + " (" + this.org[0]["organization-name"] + ")";
- }
- }
- }
- }
- return this.fn;
-}
-
-var hCard_definition = {
- mfObject: hCard,
- className: "vcard",
- required: ["fn"],
- properties: {
- "adr" : {
- plural: true,
- datatype: "microformat",
- microformat: "adr"
- },
- "agent" : {
- plural: true,
- datatype: "microformat",
- microformat: "hCard"
- },
- "bday" : {
- datatype: "dateTime"
- },
- "class" : {
- },
- "category" : {
- plural: true,
- datatype: "microformat",
- microformat: "tag",
- microformat_property: "tag"
- },
- "email" : {
- subproperties: {
- "type" : {
- plural: true,
- values: ["internet", "x400", "pref"]
- },
- "value" : {
- datatype: "email",
- virtual: true
- }
- },
- plural: true
- },
- "fn" : {
- required: true
- },
- "geo" : {
- datatype: "microformat",
- microformat: "geo"
- },
- "key" : {
- plural: true
- },
- "label" : {
- plural: true
- },
- "logo" : {
- plural: true,
- datatype: "anyURI"
- },
- "mailer" : {
- plural: true
- },
- "n" : {
- subproperties: {
- "honorific-prefix" : {
- plural: true
- },
- "given-name" : {
- plural: true
- },
- "additional-name" : {
- plural: true
- },
- "family-name" : {
- plural: true
- },
- "honorific-suffix" : {
- plural: true
- }
- },
- virtual: true,
- /* Implied "n" Optimization */
- /* http://microformats.org/wiki/hcard#Implied_.22n.22_Optimization */
- virtualGetter: function(mfnode) {
- var fn = Microformats.parser.getMicroformatProperty(mfnode, "hCard", "fn");
- var orgs = Microformats.parser.getMicroformatProperty(mfnode, "hCard", "org");
- var given_name = [];
- var family_name = [];
- if (fn && (!orgs || (orgs.length > 1) || (fn != orgs[0]["organization-name"]))) {
- var fns = fn.split(" ");
- if (fns.length === 2) {
- if (fns[0].charAt(fns[0].length-1) == ',') {
- given_name[0] = fns[1];
- family_name[0] = fns[0].substr(0, fns[0].length-1);
- } else if (fns[1].length == 1) {
- given_name[0] = fns[1];
- family_name[0] = fns[0];
- } else if ((fns[1].length == 2) && (fns[1].charAt(fns[1].length-1) == '.')) {
- given_name[0] = fns[1];
- family_name[0] = fns[0];
- } else {
- given_name[0] = fns[0];
- family_name[0] = fns[1];
- }
- return {"given-name" : given_name, "family-name" : family_name};
- }
- }
- return undefined;
- }
- },
- "nickname" : {
- plural: true,
- virtual: true,
- /* Implied "nickname" Optimization */
- /* http://microformats.org/wiki/hcard#Implied_.22nickname.22_Optimization */
- virtualGetter: function(mfnode) {
- var fn = Microformats.parser.getMicroformatProperty(mfnode, "hCard", "fn");
- var orgs = Microformats.parser.getMicroformatProperty(mfnode, "hCard", "org");
- var given_name;
- var family_name;
- if (fn && (!orgs || (orgs.length) > 1 || (fn != orgs[0]["organization-name"]))) {
- var fns = fn.split(" ");
- if (fns.length === 1) {
- return [fns[0]];
- }
- }
- return undefined;
- }
- },
- "note" : {
- plural: true,
- datatype: "HTML"
- },
- "org" : {
- subproperties: {
- "organization-name" : {
- virtual: true
- },
- "organization-unit" : {
- plural: true
- }
- },
- plural: true
- },
- "photo" : {
- plural: true,
- datatype: "anyURI"
- },
- "rev" : {
- datatype: "dateTime"
- },
- "role" : {
- plural: true
- },
- "sequence" : {
- },
- "sort-string" : {
- },
- "sound" : {
- plural: true
- },
- "title" : {
- plural: true
- },
- "tel" : {
- subproperties: {
- "type" : {
- plural: true,
- values: ["msg", "home", "work", "pref", "voice", "fax", "cell", "video", "pager", "bbs", "car", "isdn", "pcs"]
- },
- "value" : {
- datatype: "tel",
- virtual: true
- }
- },
- plural: true
- },
- "tz" : {
- },
- "uid" : {
- datatype: "anyURI"
- },
- "url" : {
- plural: true,
- datatype: "anyURI"
- }
- }
-};
-
-Microformats.add("hCard", hCard_definition);
-
-this.hCalendar = function hCalendar(node, validate) {
- if (node) {
- Microformats.parser.newMicroformat(this, node, "hCalendar", validate);
- }
-}
-hCalendar.prototype.toString = function() {
- if (this.resolvedNode) {
- /* If this microformat has an include pattern, put the */
- /* dtstart in parenthesis after the summary to differentiate */
- /* them. */
- var summaries = Microformats.getElementsByClassName(this.node, "summary");
- if (summaries.length === 0) {
- if (this.summary) {
- if (this.dtstart) {
- return this.summary + " (" + Microformats.dateFromISO8601(this.dtstart).toLocaleString() + ")";
- }
- }
- }
- }
- if (this.dtstart) {
- return this.summary;
- }
- return undefined;
-}
-
-var hCalendar_definition = {
- mfObject: hCalendar,
- className: "vevent",
- required: ["summary", "dtstart"],
- properties: {
- "category" : {
- plural: true,
- datatype: "microformat",
- microformat: "tag",
- microformat_property: "tag"
- },
- "class" : {
- values: ["public", "private", "confidential"]
- },
- "description" : {
- datatype: "HTML"
- },
- "dtstart" : {
- datatype: "dateTime"
- },
- "dtend" : {
- datatype: "dateTime"
- },
- "dtstamp" : {
- datatype: "dateTime"
- },
- "duration" : {
- },
- "geo" : {
- datatype: "microformat",
- microformat: "geo"
- },
- "location" : {
- datatype: "microformat",
- microformat: "hCard"
- },
- "status" : {
- values: ["tentative", "confirmed", "cancelled"]
- },
- "summary" : {},
- "transp" : {
- values: ["opaque", "transparent"]
- },
- "uid" : {
- datatype: "anyURI"
- },
- "url" : {
- datatype: "anyURI"
- },
- "last-modified" : {
- datatype: "dateTime"
- },
- "rrule" : {
- subproperties: {
- "interval" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "interval");
- }
- },
- "freq" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "freq");
- }
- },
- "bysecond" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bysecond");
- }
- },
- "byminute" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byminute");
- }
- },
- "byhour" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byhour");
- }
- },
- "bymonthday" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bymonthday");
- }
- },
- "byyearday" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byyearday");
- }
- },
- "byweekno" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byweekno");
- }
- },
- "bymonth" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bymonth");
- }
- },
- "byday" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byday");
- }
- },
- "until" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "until");
- }
- },
- "count" : {
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "count");
- }
- }
- },
- retrieve: function(mfnode, property) {
- var value = Microformats.parser.textGetter(mfnode);
- var rrule;
- rrule = value.split(';');
- for (let i=0; i < rrule.length; i++) {
- if (rrule[i].match(property)) {
- return rrule[i].split('=')[1];
- }
- }
- return undefined;
- }
- }
- }
-};
-
-Microformats.add("hCalendar", hCalendar_definition);
-
-this.geo = function geo(node, validate) {
- if (node) {
- Microformats.parser.newMicroformat(this, node, "geo", validate);
- }
-}
-geo.prototype.toString = function() {
- if (this.latitude != undefined) {
- if (!isFinite(this.latitude) || (this.latitude > 360) || (this.latitude < -360)) {
- return undefined;
- }
- }
- if (this.longitude != undefined) {
- if (!isFinite(this.longitude) || (this.longitude > 360) || (this.longitude < -360)) {
- return undefined;
- }
- }
-
- if ((this.latitude != undefined) && (this.longitude != undefined)) {
- var s;
- if ((this.node.localName.toLowerCase() == "abbr") || (this.node.localName.toLowerCase() == "html:abbr")) {
- s = this.node.textContent;
- }
-
- if (s) {
- return s;
- }
-
- /* check if geo is contained in a vcard */
- var xpathExpression = "ancestor::*[contains(concat(' ', @class, ' '), ' vcard ')]";
- var xpathResult = this.node.ownerDocument.evaluate(xpathExpression, this.node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, null);
- if (xpathResult.singleNodeValue) {
- var hcard = new hCard(xpathResult.singleNodeValue);
- if (hcard.fn) {
- return hcard.fn;
- }
- }
- /* check if geo is contained in a vevent */
- xpathExpression = "ancestor::*[contains(concat(' ', @class, ' '), ' vevent ')]";
- xpathResult = this.node.ownerDocument.evaluate(xpathExpression, this.node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, xpathResult);
- if (xpathResult.singleNodeValue) {
- var hcal = new hCalendar(xpathResult.singleNodeValue);
- if (hcal.summary) {
- return hcal.summary;
- }
- }
- if (s) {
- return s;
- } else {
- return this.latitude + ", " + this.longitude;
- }
- }
- return undefined;
-}
-
-var geo_definition = {
- mfObject: geo,
- className: "geo",
- required: ["latitude","longitude"],
- properties: {
- "latitude" : {
- datatype: "float",
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- var value = Microformats.parser.textGetter(mfnode);
- var latlong;
- if (value.match(';')) {
- latlong = value.split(';');
- if (latlong[0]) {
- if (!isNaN(latlong[0])) {
- return parseFloat(latlong[0]);
- }
- }
- }
- return undefined;
- }
- },
- "longitude" : {
- datatype: "float",
- virtual: true,
- /* This will only be called in the virtual case */
- virtualGetter: function(mfnode) {
- var value = Microformats.parser.textGetter(mfnode);
- var latlong;
- if (value.match(';')) {
- latlong = value.split(';');
- if (latlong[1]) {
- if (!isNaN(latlong[1])) {
- return parseFloat(latlong[1]);
- }
- }
- }
- return undefined;
- }
- }
- },
- validate: function(node) {
- var latitude = Microformats.parser.getMicroformatProperty(node, "geo", "latitude");
- var longitude = Microformats.parser.getMicroformatProperty(node, "geo", "longitude");
- if (latitude != undefined) {
- if (!isFinite(latitude) || (latitude > 360) || (latitude < -360)) {
- throw("Invalid latitude");
- }
- } else {
- throw("No latitude specified");
- }
- if (longitude != undefined) {
- if (!isFinite(longitude) || (longitude > 360) || (longitude < -360)) {
- throw("Invalid longitude");
- }
- } else {
- throw("No longitude specified");
- }
- return true;
- }
-};
-
-Microformats.add("geo", geo_definition);
-
-this.tag = function tag(node, validate) {
- if (node) {
- Microformats.parser.newMicroformat(this, node, "tag", validate);
- }
-}
-tag.prototype.toString = function() {
- return this.tag;
-}
-
-var tag_definition = {
- mfObject: tag,
- attributeName: "rel",
- attributeValues: "tag",
- properties: {
- "tag" : {
- virtual: true,
- virtualGetter: function(mfnode) {
- if (mfnode.href) {
- var ioService = Components.classes["@mozilla.org/network/io-service;1"].
- getService(Components.interfaces.nsIIOService);
- var uri = ioService.newURI(mfnode.href, null, null);
- var url_array = uri.path.split("/");
- for(let i=url_array.length-1; i > 0; i--) {
- if (url_array[i] !== "") {
- var tag
- if (tag = Microformats.tag.validTagName(url_array[i].replace(/\+/g, ' '))) {
- try {
- return decodeURIComponent(tag);
- } catch (ex) {
- return unescape(tag);
- }
- }
- }
- }
- }
- return null;
- }
- },
- "link" : {
- virtual: true,
- datatype: "anyURI"
- },
- "text" : {
- virtual: true
- }
- },
- validTagName: function(tag)
- {
- var returnTag = tag;
- if (tag.indexOf('?') != -1) {
- if (tag.indexOf('?') === 0) {
- return false;
- } else {
- returnTag = tag.substr(0, tag.indexOf('?'));
- }
- }
- if (tag.indexOf('#') != -1) {
- if (tag.indexOf('#') === 0) {
- return false;
- } else {
- returnTag = tag.substr(0, tag.indexOf('#'));
- }
- }
- if (tag.indexOf('.html') != -1) {
- if (tag.indexOf('.html') == tag.length - 5) {
- return false;
- }
- }
- return returnTag;
- },
- validate: function(node) {
- var tag = Microformats.parser.getMicroformatProperty(node, "tag", "tag");
- if (!tag) {
- if (node.href) {
- var url_array = node.getAttribute("href").split("/");
- for(let i=url_array.length-1; i > 0; i--) {
- if (url_array[i] !== "") {
- throw("Invalid tag name (" + url_array[i] + ")");
- }
- }
- } else {
- throw("No href specified on tag");
- }
- }
- return true;
- }
-};
-
-Microformats.add("tag", tag_definition);
--- a/toolkit/components/microformats/moz.build
+++ b/toolkit/components/microformats/moz.build
@@ -1,13 +1,12 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
- 'microformat-shiv.js',
- 'Microformats.js',
+ 'microformat-shiv.js'
]
with Files('**'):
BUG_COMPONENT = ('Toolkit', 'Microformats')
deleted file mode 100644
--- a/toolkit/components/microformats/tests/.eslintrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "extends": [
- "../../../../testing/mochitest/mochitest.eslintrc"
- ]
-}
deleted file mode 100644
--- a/toolkit/components/microformats/tests/geo.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <body>
- <span class="geo" id="01-geo-abbr-latlong" >
- <abbr class="latitude" title="37.77">Northern</abbr>
- <abbr class="longitude" title="-122.41">California</abbr>
- </span>
- </body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/mochitest.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[DEFAULT]
-skip-if = buildapp == 'b2g'
-support-files = geo.html
-
-[test_Microformats.html]
-[test_Microformats_add.html]
-[test_Microformats_adr.html]
-[test_Microformats_count.html]
-[test_Microformats_geo.html]
-[test_Microformats_getters.html]
-[test_Microformats_hCalendar.html]
-[test_Microformats_hCard.html]
-[test_Microformats_negative.html]
-[test_framerecursion.html]
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats.html
+++ /dev/null
@@ -1,301 +0,0 @@
-<html>
-<head>
- <title>Testing Microformats.js</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
- <style type="text/css">
- /*vcards weee! */
- .floated div {
- float:left;
- }
- </style>
-
-</head>
-<body>
-<div id="content" style="display: none">
- <div id="test_1">
- <div class="vcard" id="vcard1_node">
- <a class="url fn" href="http://tantek.com/">Tantek Çelik</a>
- <div id="vcard1_org" class="org">Technorati</div>
- </div>
- <div class="vcard" id="vcard2_node">
- <a class="url" href="http://tantek.com/">Tantek Çelik</a>
- <div id="vcard2_org" class="org">Technorati</div>
- </div>
- </div>
- <div class="vcard" id="outer_vcard">
- <div class="vcard" id="middle_vcard">
- <div class="vcard" id="inner_vcard">
- <span class="fn">Inner User</span>
- </div>
- <span class="fn">Middle User</span>
- </div>
- <span class="fn">Outer User</span>
- </div>
- <div class="vcard" id="outer_vcard2">
- <div class="vevent" id="middle_vevent2">
- <div class="vcard" id="inner_vcard2">
- <span class="fn">Inner User</span>
- </div>
- <span class="summary">Middle Event</span>
- </div>
- <span class="fn">Outer User</span>
- </div>
- <div class="vevent" id="outer_vevent3">
- <div class="vcard" id="middle_vcard3">
- <div class="vevent" id="inner_vevent3">
- <span class="summary">Inner Event</span>
- </div>
- <span class="fn">Middle User</span>
- </div>
- <span class="summary">Outer Event</span>
- </div>
-
- <div class="vevent" id="outer_vevent4">
- <a rel="tag" id="inner_tag4" href="http://www.example.com/inner_tag">
- Inner tag
- </a>
- <span class="summary">Outer Event</span>
- </div>
-
- <a rel="tag" id="outer_tag5" href="http://www.example.com/outer_tag">
- <div class="vevent" id="inner_vevent5">
- <span class="summary">Inner Event</span>
- </div>
- </a>
-
- <div class="vcard" id="value_test">
- <span class="fn">
- <span class="value">John</span>
- <span><span class="value">Middle</span></span>
- <span class="value">Doe</span>
- </span>
- </div>
-
- <div class="vcard" id="nested_vcard1">
- <div class="agent vcard" id="nested_vcard2">
- <div class="agent vcard" id="nested_vcard3">
- <span class="fn">Bob Smith</span>
- <span class="title">Office Assistant</span>
- </div>
- <span class="fn">Jack Jones</span>
- <span class="title">Executive Assistant</span>
- </div>
- <span class="fn">John Doe</span>
- <span class="title">CEO</span>
- </div>
-
- <div class="vevent" id="date_vcal">
- <span class="description">Mozilla's Birthday</span>
- <span class="dtstart">1998-01-22</span>
- </div>
-
- <div class="vevent" id="vcal_vcard">
- <div class="vcard">
- <span class="description">
- <span class="fn org">Mozilla</span>'s Birthday
- </span>
- </div>
- <span class="dtstart">1998-01-22</span>
- </div>
-
- <div id="geo_vcard" class="vcard">
- <span class="fn">John Doe</span>
- <span class="geo" id="ill_geo5">abc;def</span>
- </div>
- <div id="loc_vevent" class="vevent">
- <span class="summary">Party</span>
- <span class="location">The White House</span>
- </div>
- <div id="loc_vcard_vevent" class="vevent">
- <span class="summary">Party</span>
- <span class="location vcard"><span class="fn">The White House</span></span>
- </div>
-
- <div class="vcard" id="valuespace_1">
- <span class="fn">
- <span class="value">John</span>
- <span class="value"> </span>
- <span class="value">Doe</span>
- </span>
- </div>
- <div class="vcard" id="valuespace_2">
- <span class="fn">
- <span class="value">John</span>
- <span class="value"> </span>
- <span class="value">Doe</span>
- </span>
- </div>
- <div class="vcard" id="valuespace_3">
- <span class="fn">
- <span class="value"> John</span>
- <span class="value"> </span>
- <span class="value">Doe </span>
- </span>
- </div>
- <div class="vcard" id="valuespace_4">
- <span class="fn">
- <span class="value">John </span>
- <span class="value"> Doe</span>
- </span>
- </div>
- <div class="vcard" id="valuespace_5">
- <span class="fn">
- <span class="value"> John</span>
- <span class="value"> Doe </span>
- </span>
- </div>
- <div class="vcard" id="valuespace_6">
- <span class="fn">
- <span class="value">John
- </span>
- <span class="value">
- Doe</span>
- </span>
- </div>
- <div class="vcard" id="valuespace_7">
- <span class="fn">
- <span class="value">John</span>
- <span class="value">Doe</span>
- </span>
- </div>
-
- <span id="austin" class="location">Austin - Sixth Street</span>
- <table summary="Timetable">
- <thead>
- <tr>
- <th id="location-1"><a href="#austin" class="include"></a>New York</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th id="time-1"><abbr title="2008-01-01" class="dtstart">Jan 1, 2008</abbr></th>
- <td id="nested_header_include" class="vevent" headers="time-1 location-1"><div class="summary">New Years Party</div></td>
- </tr>
- </tbody>
- </table>
-
-</div>
-
-<div id="float_test">
- <div class="vcard floated" id="one">
- <div class="fn">John Doe</div>
- </div>
- <div class="vcard" id="two">
- <div class="fn">John Smith</div>
- </div>
-</div>
-
-<pre id="test">
-<script class="testbody" type="application/javascript;version=1.8">
-
-test_Microformats();
-test_hCard();
-
-function test_Microformats() {
- let { Microformats, hCard, hCalendar } = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js");
-
- ok(Microformats, "Check global access to Microformats");
- var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
- is(hCards.length, 1, "Check Microformats.get");
- is(Microformats.count("hCard", document.getElementById("test_1"), {showHidden: true}), 1, "Check Microformats.count");
- is(Microformats.count("hCard", document.getElementById("test_1"), {showHidden: true, debug: true}), 2, "Check Microformats.count (debug)");
- ok(Microformats.isMicroformat(document.getElementById("vcard1_node")), "Check isMicroformat");
- is(SpecialPowers.unwrap(Microformats.getParent(document.getElementById("vcard1_org"))), document.getElementById("vcard1_node"), "Check getParent");
- is(Microformats.getNamesFromNode(document.getElementById("vcard1_node")), "hCard", "Check getNamesFromNode");
-
- var hCardArray1 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
- is(hCardArray1.length, 1, "Check showHidden=true");
- var hCardArray2 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: false});
- is(hCardArray2.length, 0, "Check showHidden=false");
-
- var inner_parent = Microformats.getParent(document.getElementById("inner_vcard"));
- is(inner_parent.id, "middle_vcard", "GetParent gets correct ancestor 1");
-
- var inner_parent = Microformats.getParent(document.getElementById("inner_vcard2"));
- is(inner_parent.id, "middle_vevent2", "GetParent gets correct ancestor 2");
-
- var inner_parent = Microformats.getParent(document.getElementById("middle_vevent2"));
- is(inner_parent.id, "outer_vcard2", "GetParent gets correct ancestor 2a");
-
- var inner_parent = Microformats.getParent(document.getElementById("inner_vevent3"));
- is(inner_parent.id, "middle_vcard3", "GetParent gets correct ancestor 3");
-
- var inner_parent = Microformats.getParent(document.getElementById("middle_vcard3"));
- is(inner_parent.id, "outer_vevent3", "GetParent gets correct ancestor 3a");
-
- var inner_parent = Microformats.getParent(document.getElementById("inner_tag4"));
- is(inner_parent.id, "outer_vevent4", "GetParent gets correct ancestor 4");
-
- var inner_parent = Microformats.getParent(document.getElementById("inner_vevent5"));
- is(inner_parent.id, "outer_tag5", "GetParent gets correct ancestor 5");
-
- var valueCard = new hCard(document.getElementById("value_test"));
-
- is(valueCard.fn, "JohnDoe", "value_test");
-
- var nestCard1 = new hCard(document.getElementById("nested_vcard1"));
- var nestCard2 = new hCard(document.getElementById("nested_vcard2"));
- var nestCard3 = new hCard(document.getElementById("nested_vcard3"));
-
- is(nestCard1.fn, "John Doe", "nesting (fn) 1");
- is(String(nestCard1.title), "CEO", "nesting (title) 1");
- is(nestCard2.fn, "Jack Jones", "nesting (fn) 2");
- is(String(nestCard2.title), "Executive Assistant", "nesting (title) 2");
- is(nestCard3.fn, "Bob Smith", "nesting (fn) 3");
- is(String(nestCard3.title), "Office Assistant", "nesting (title) 3");
- is(nestCard1.agent[0].agent[0].fn, "Bob Smith", "nesting all");
-
- var dateCal = new hCalendar(document.getElementById("date_vcal"));
- jsdate = Microformats.dateFromISO8601(dateCal.dtstart);
- origdate = Microformats.iso8601FromDate(jsdate, true);
- is(dateCal.dtstart, origdate, "date round trip");
-
- var dateCal = new hCalendar(document.getElementById("vcal_vcard"));
- is(String(dateCal.description), "Mozilla's Birthday", "vcard in vcal");
-
- is(Microformats.count("hCard", document.getElementById("float_test")), 2, "Check Microformats.count for floated div");
-
- var hcard = new hCard(document.getElementById("geo_vcard"));
- ok(!hcard.geo, "Check if invalid geo does not exist");
- var hcal = new hCalendar(document.getElementById("loc_vevent"));
- is(hcal.location, "The White House", "Check if non vcard location works");
- var hcal = new hCalendar(document.getElementById("loc_vcard_vevent"));
- is(hcal.location.fn, "The White House", "Check if vcard location works");
-
- var nestedCal = new hCalendar(document.getElementById("nested_header_include"));
- is(nestedCal.dtstart, "2008-01-01", "nested_header_include - dtstart");
- is(nestedCal.location, "Austin - Sixth Street", "nested_header_include - location");
- is(nestedCal.summary, "New Years Party", "nested_header_include - summary");
-
- var valueCard = new hCard(document.getElementById("valuespace_1"));
- is(valueCard.fn, "John Doe", "valuespace_1");
- var valueCard = new hCard(document.getElementById("valuespace_2"));
- is(valueCard.fn, "John Doe", "valuespace_2");
- var valueCard = new hCard(document.getElementById("valuespace_3"));
- is(valueCard.fn, "John Doe", "valuespace_3");
- var valueCard = new hCard(document.getElementById("valuespace_4"));
- is(valueCard.fn, "John Doe", "valuespace_4");
- var valueCard = new hCard(document.getElementById("valuespace_5"));
- is(valueCard.fn, "John Doe", "valuespace_5");
- var valueCard = new hCard(document.getElementById("valuespace_6"));
- is(valueCard.fn, "John Doe", "valuespace_6");
- var valueCard = new hCard(document.getElementById("valuespace_7"));
- is(valueCard.fn, "JohnDoe", "valuespace_7");
-
-}
-
-function test_hCard() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
-
- is(hCards[0].fn, "Tantek Çelik", "Check for fn on test vcard");
- is(String(hCards[0].url), "http://tantek.com/", "Check for url on test vcard");
-}
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_add.html
+++ /dev/null
@@ -1,238 +0,0 @@
-<html>
-<head>
- <title>Testing Mixed Up Microformat APIs</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body id="contentbody">
-
- <!-- Parsing tests are well covered, we're going to do some data type stuff
- here -->
- <div id="test1">
- <p class="mftest" id="mftest-version1">
- <span class="title"><b>Can Really be Anything, even HTML</b></span>
- <span class="htmlval"><i>foo</i></span>
- <span class="htmlval">what about just text?</span>
- <span class="tel">011-23-45-7867-897890</span>
- <span class="uri">http://www.mozilla.org </span>
- <span class="email">mailto:joe@nowhere.org</span>
- <span class="geo">
- <span class="latitude">0.0</span>
- <span class="longitude">0.0</span>
- </span>
- <span class="date">20080401T235900</span>
- </p>
- </div>
-
- <!-- This one is invalid until we add the new version of the hTest MF -->
- <div id="test2">
- <span class="mftest" id="mftest-version2">
- <abbr class="title" title="<b>Can Really be Anything, even HTML</b>"/>
- <span class="uri" title="http://www.mozilla.org"/>
- <abbr class="email" title="joe@nowhere.org">joe's email</ABBR>
- <span class="geo">
- <span class="latitude">0.0</span>
- <span class="longitude">0.0"</span>
- </span>
- <!-- Throw a zulu in there! -->
- <span class="date" title="20080401T235900Z"/>
- </span>
- </div>
-
- <!-- This one is invalid in both versions (no title)-->
- <div id="test3">
- <div class="mftest">
- <abbr class="htmlval" title="what about just text?">more values</abbr>
- <span class="uri">http://foo.com</span>
- </div>
- </div>
-
- <!-- Contains an invalid geo -->
- <div id="test4">
- <span class="mftest">
- <abbr class="title" title="<b>Can Really be Anything, even HTML</b>"/>
- <abbr class="htmlval" title="<html><body>foo</body></html>">
- An HTML document!
- </abbr>
- <abbr class="htmlval" title="what about just text?">more values</abbr>
- <span class="tel" title="011-23-45-7867-897890"/>
- <span class="uri" title="http://www.mozilla.org"/>
- <abbr class="email" title="joe@nowhere.org">joe's email</ABBR>
- <span class="geo">
- <span class="latitude">659</span>
- <span class="longitude">-362.5</span>
- </span>
- <span class="date" title="20080401T235900"/>
- </span>
- </div>
-
- <!-- Contains an invalid date -->
- <div id="test5">
- <span class="mftest">
- <abbr class="title htmlval" title="another test">thehtmlvaltodoescapeme</abbr>
- <abbr class="date" title="200311T032Z">invalid date</abbr>
- </span>
- </div>
-
- <!-- Ok, the test, here we go -->
- <pre id="test">
- <script class="testbody" type="text/javascript">
-
- function hTest(node, validate) {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
- if (node)
- Microformats.parser.newMicroformat(this, node, "hTest", validate);
- }
-
- hTest.prototype.toString = function () {
- return("This is a test");
- }
-
- // Define a new microformat to add to the Microformats collection
- var hTest_definition = {
- mfObject: hTest,
- className: "mftest",
- required: ["title", "htmlval"],
- properties: {
- "title" : {},
- "htmlval" : {
- plural: true,
- datatype: "HTML"
- },
- "tel" : {
- datatype: "tel",
- },
- "uri" : {
- dataypte: "anyURI"
- },
- "email" : {
- datatype: "email"
- },
- "geo" : {
- datatype: "microformat",
- microformat: "geo"
- },
- "date" : {
- datatype: "dateTime",
- }
- }
- };
-
- // Define another version of this microformat to overwrite it - this one
- // removes the requirement to have a htmlval and also removes the tel prop.
- var hTest_definition2 = {
- mfObject: hTest,
- className: "mftest",
- required: ["title"],
- properties: {
- "title" : {},
- "htmlval" : {
- plural: true,
- datatype: "HTML"
- },
- "uri" : {
- dataypte: "anyURI"
- },
- "email" : {
- datatype: "email"
- },
- "geo" : {
- datatype: "microformat",
- microformat: "geo"
- },
- "date" : {
- datatype: "dateTime",
- }
- }
- };
- test_MicroformatsAPI();
-
- function doTest3_4_and5() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
- ok(Microformats, "Make sure we still have a microformats object");
-
- var mfs = Microformats.get("hTest",
- document.getElementById("test3"),
- {recurseExternalFrames: true});
-
- is(mfs.length, 0, "Check hTest 3 is invalid");
-
- mfs = Microformats.get("hTest",
- document.getElementById("test4"),
- {recurseExternalFrames: true});
-
- is(mfs.length, 1, "Check hTest 4 is valid");
- // Test 4 is a valid hTest, but it's embedded Geo is invalid,
- // test that assumption
- ok(!(mfs.geo), "Ensure that the test 4 geo is reporting as invalid");
-
- mfs = Microformats.get("hTest",
- document.getElementById("test5"),
- {recurseExternalFrames: true});
- is(mfs.length, 1, "Check hTest 5 is valid");
-
- try {
- var jsDate = new Date(Microformats.parser.dateFromISO8601(mfs[0].date));
- ok(false, "Invalid JS Date should throw");
- } catch (ex) {
- ok(true, "Check that getting invalid jsdate throws");
- }
- }
-
- function test_MicroformatsAPI() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- // Make sure they aren't microformats yet
- is(Microformats.isMicroformat(document.getElementById("mftest-version1")),
- false, "Check that the mfTest microformat does not exist yet");
-
- try {
- Microformats.add("hTest", hTest_definition);
- } catch (ex) {
- ok(false, "Threw while adding hTest definition 1");
- }
-
- ok(Microformats.isMicroformat(document.getElementById("mftest-version1")),
- "Check that the mfTest microformat now exists");
-
- var mf = Microformats.get("hTest", document.getElementById("test1"),
- {recurseExternalFrames: true});
-
- is(mf.length, 1, "Check that test1 is a valid microformat");
- is(mf[0].title, "Can Really be Anything, even HTML", "Check test1 title");
-
- is(mf[0].geo.latitude, 0.0, "Check test1 geo");
-
- // Make sure that our test2 doesn't pass validation until we add
- // version 2 of the hTest microformat
- var mf2 = Microformats.get("hTest", document.getElementById("test2"), {});
- is(mf2.length, 0, "Check that the mfTest microformat version 2 is not a MF");
-
- doTest3_4_and5(false);
-
- // Ok, add the version 2 hTest
- try {
- Microformats.add("hTest", hTest_definition2);
- } catch (ex) {
- ok(false, "Threw while adding hTest definition 2");
- }
-
- // The old version's microformat is still valid
- mf = Microformats.get("hTest", document.getElementById("test1"),
- {recurseExternalFrames: true});
-
- ok(mf.length, 1, "Check that test1 is a valid microformat");
-
- // Verify that the version 2 microformat is now also considered valid
- mf2 = Microformats.get("hTest", document.getElementById("test2"), {});
-
- ok(mf2.length, 1, "Check that the mfTest microformat version 2 is now valid");
- doTest3_4_and5(true);
-
- Microformats.remove("hTest");
- }
-
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_adr.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title>Testing Microformats.js (adr)</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body>
-<div id="content" style="display: none">
- <div class="adr" id="01-extended-address">
- <span class="extended-address">Park Bench</span>
- </div>
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-test_Microformats();
-test_adr();
-
-function test_Microformats() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- ok(Microformats, "Check global access to Microformats");
-}
-
-function test_adr() {
- var adr = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").adr;
-
- var address;
-
- address = new adr(document.getElementById("01-extended-address"));
-
- is(address.toString(), "Park Bench", "01-extended-address");
-}
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_count.html
+++ /dev/null
@@ -1,154 +0,0 @@
-<html>
-<head>
- <title>Testing Mixed Up Microformat APIs</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body id="contentbody">
- <!-- hCard -->
- <p class="vcard" id="23-abbr-title-everything">
-<!-- perhaps the most annoying test ever -->
- <abbr class="fn" title="John Doe">foo</abbr>
- <span class="n">
- <abbr class="honorific-prefix" title="Mister">Mr.</abbr>
- <abbr class="given-name" title="Jonathan">John</abbr>
- <abbr class="additional-name" title="John">J</abbr>
- <abbr class="family-name" title="Doe-Smith">Doe</abbr>
- <abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
- </span>
- <abbr class="nickname" title="JJ">jj</abbr>
- <abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
- <span class="adr">
- <abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
- <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
- <abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
- <abbr class="locality" title="San Francisco">San Fran</abbr>
- <abbr class="region" title="California">CA</abbr>
- <abbr class="postal-code" title="12345-6789">12345</abbr>
- <abbr class="country-name" title="United States of America">USA</abbr>
- <abbr class="type" title="work">workplace</abbr>
- </span>
- <abbr class="tel" title="415.555.1234">1234</abbr>
- <abbr class="tel-type-value" title="work">workplace</abbr>
-<!-- mailer -->
- <abbr class="tz" title="-0700">Pacific Time</abbr>
- <span class="geo">
- <abbr class="latitude" title="37.77">Northern</abbr>
- <abbr class="longitude" title="-122.41">California</abbr>
- </span>
- <abbr class="title" title="President">pres.</abbr> and
- <abbr class="role" title="Chief">cat wrangler</abbr>
-<!-- <span class="agent"></span> -->
- <span class="org">
- <abbr class="organization-name" title="Intellicorp">foo</abbr>
- <abbr class="organization-unit" title="Intelligence">bar</abbr>
- </span>
-<!-- <abbr class="category" title=""></abbr> -->
- <abbr class="note" title="this is a note">this is not a note</abbr>
-<!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
-<!-- <abbr class="sort-string" title=""></abbr> -->
- <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
- <abbr class="class" title="public">pub</abbr>
-<!-- <abbr class="key" title=""></abbr> -->
- </p>
-
- <!-- hCalendar -->
- <frameset>
- <frame id="frame1">
- <div>
- <span class="notAMicroformat" id="notme">
- <abbr> class="foo">I am not a microformat</abbr>
- <abbr> class="title">Foolish title, not a format</abbr>
- </span>
- </div>
- </frame>
- <frame id="frame3">
- <span class="geo" id="02-geo-abbr-latlong" >
- <abbr class="latitude" title="75.77">Far Northern</abbr>
- <abbr class="longitude" title="-122.41">Canada</abbr>
- </span>
- <frame id="frame2">
- <div class="vcalendar">
- <span class="vevent" id="15-calendar-xml-lang">
- <a class="url" href="http://www.web2con.com/">
- <span class="summary">Web 2.0 Conference</span>:
- <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
- </frame>
- </frameset>
-
- <!-- Put the test code before the iframe just to be
- extra-sure it's been evaluated before the iframe onload fires -->
- <script class="testbody" type="text/javascript">
- // Called from the onload of the iframe
- function test_MicroformatsAPI() {
- // I'm going to try to do this without getting XPConnect priv's, make sure
- // we throw
- try {
- Components.utils.import("resource://gre/modules/Microformats.js");
- ok(false, "Should not execute this code");
- } catch(ex) {
- ok(true, "Expected exception");
- }
-
- // Gonna do things the right way
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- // Test Microformat frame recursion - start with counting
- var count = Microformats.count("adr",
- document.getElementById("contentbody"),
- {recurseExternalFrames: false}, // do not recurse frames
- 0); // current count
- is(count, 2, "No frame recursion, finds 2 adr's (none in frames)");
-
- // Try it with frame recursion
- count = Microformats.count("adr",
- document.getElementById("contentbody"),
- {recurseExternalFrames: true},
- count);
- // Should still find 2
- is(count, 2, "Only 2 adr nodes, even when recursing frames");
-
- // Since "recurseExternalFrames" only affects the external frames, the microformat
- // in the <frameset> will always be counted.
- count = Microformats.count("geo",
- document.getElementById("contentbody"),
- {recurseExternalFrames: false},
- 0);
- is(count, 2, "Should find two geo if we don't recurse external frames");
-
- count = Microformats.count("geo",
- document.getElementById("contentbody"),
- {recurseExternalFrames: true},
- 0);
- is(count, 3, "Three geos,one outside, one in a frameset, and one in iframe");
-
- count = Microformats.count("hCalendar",
- document.getElementById("contentbody"),
- {recurseExternalFrames: true},
- 0);
- is(count, 1, "One hCalendar");
-
- count = Microformats.count("hCard",
- document.getElementById("contentbody"),
- {recurseExternalFrames: true});
- is(count, 1, "One hCard");
- }
- </script>
-
- <!-- Geo Fire the test from here so we know this is loaded at the outset -->
- <iframe src="geo.html" onload="test_MicroformatsAPI();">
- </iframe>
-
- <!-- adr -->
- <div class="adr" id="01-extended-address">
- <span class="extended-address">Park Bench</span>
- </div>
-
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_geo.html
+++ /dev/null
@@ -1,218 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title>Testing Microformats.js (geo)</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body>
-<div id="content" style="display: none">
-
- <span class="geo" id="01-geo-basic">
- <span class="latitude">37.77</span>
- <span class="longitude">-122.411</span>
- </span>
-
-
- <span class="geo" id="01-geo-abbr-latlong" >
- <abbr class="latitude" title="37.77">Northern</abbr>
- <abbr class="longitude" title="-122.41">California</abbr>
- </span>
-
- <abbr class="geo" id="01-geo-abbr" title="30.267991;-97.739568">Paradise</abbr>
-
- <span class="vcard">
- <span class="fn org">John Doe</span>
- <abbr class="geo" id="02-geo-vcard-01" title="37.77;-122.41"></abbr>
- </span>
-
- <span class="vcard">
- <span class="fn org">John Doe</span>
- <abbr class="geo" id="02-geo-vcard-02" title="37.77;-122.41">Northern California</abbr>
- </span>
-
- <span class="vevent">
- <span class="summary">SXSW Interactive (South by Southwest)</span>
- <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR>
- -
- <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR>
- <abbr class="geo" id="02-geo-vevent-01" title="30.2622;-97.7399"></abbr>
- </span>
-
- <span class="vevent">
- <span class="summary">SXSW Interactive (South by Southwest)</span>
- <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR>
- -
- <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR>
- <abbr class="geo" id="02-geo-vevent-02" title="30.2622;-97.7399">Convention Center</abbr>
- </span>
-
-<h3>Legal geos</h3>
-<ul>
-<li><span class="geo" id="legal_geo1"><span class="latitude">0</span>,<span class="longitude">0</span></span></li>
-<li><span class="geo" id="legal_geo2"><span class="latitude">0.0</span>,<span class="longitude">0.0</span></span></li>
-<li><span class="geo" id="legal_geo3"><span class="latitude">0.</span>,<span class="longitude">0.</span></span></li>
-</ul>
-<h3>Illegal geos</h3>
-
-<ul>
-<li><span class="geo" id="ill_geo1"><span class="latitude">abc</span>,<span class="longitude">def</span></span></li>
-<li><span class="geo" id="ill_geo2"><span class="latitude">12.s2</span>,<span class="longitude">1d.23</span></span></li>
-<li><span class="geo" id="ill_geo3"><span class="latitude">999.99</span>,<span class="longitude">999</span></span></li>
-<li><span class="geo" id="ill_geo4"><span class="latitude">-181</span>,<span class="longitude">-361</span></span></li>
-<li><span class="geo" id="ill_geo5">abc;def</span></li>
-<li><span class="geo" id="ill_geo6">12.s2;1d.23</span></li>
-<li><span class="geo" id="ill_geo7">999.99;999</span></li>
-<li><span class="geo" id="ill_geo8">-181;-361</span></li>
-<li><span class="geo" id="ill_geo9">-18;;-31</span></li>
-<li><ABBR title="+23.70000;+90.30000" class="extra_geo">Dhaka, Bangladesh</ABBR></li>
-<li><span class="geo" id="zero_geo">0;0</span></li>
-</ul>
-
-
-
-
-
-
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-test_Microformats();
-test_geo();
-
-function test_Microformats() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- ok(Microformats, "Check global access to Microformats");
-}
-
-function test_geo() {
- var geo = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").geo;
-
- var Geo;
-
- Geo = new geo(document.getElementById("01-geo-basic"));
-
- is(Geo.latitude, 37.77, "01-geo-basic - latitude");
- is(Geo.longitude, -122.411, "01-geo-basic - longitude");
-
- Geo = new geo(document.getElementById("01-geo-abbr-latlong"));
-
- is(Geo.latitude, 37.77, "02-geo-abbr-latlong - latitude");
- is(Geo.longitude, -122.41, "02-geo-abbr-latlong - longitude");
-
- Geo = new geo(document.getElementById("01-geo-abbr"));
-
- is(Geo.latitude, 30.267991, "01-geo-abbr - latitude");
- is(Geo.longitude, -97.739568, "01-geo-abbr - longitude");
-
- Geo = new geo(document.getElementById("02-geo-vcard-01"));
-
- is(Geo.toString(), "John Doe", "02-geo-vcard-01");
-
- Geo = new geo(document.getElementById("02-geo-vcard-02"));
-
- is(Geo.toString(), "Northern California", "02-geo-vcard-02");
-
- Geo = new geo(document.getElementById("02-geo-vevent-01"));
-
- is(Geo.toString(), "SXSW Interactive (South by Southwest)", "02-geo-vevent-01");
-
- Geo = new geo(document.getElementById("02-geo-vevent-02"));
-
- is(Geo.toString(), "Convention Center", "02-geo-vevent-02");
-
- Geo = new geo(document.getElementById("legal_geo1"));
-
- is(Geo.latitude, 0, "legal_geo1 - lat");
- is(Geo.longitude, 0, "legal_geo1 - long");
-
- Geo = new geo(document.getElementById("legal_geo2"));
-
- is(Geo.latitude, 0, "legal_geo2 - lat");
- is(Geo.longitude, 0, "legal_geo2 - long");
-
- Geo = new geo(document.getElementById("legal_geo3"));
-
- is(Geo.latitude, 0, "legal_geo3 - lat");
- is(Geo.longitude, 0, "legal_geo3 - long");
-
-
-
-
- try {
- Geo = new geo(document.getElementById("ill_geo1"), true);
- ok(0, "ill_geo1 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo1 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo2"), true);
- ok(0, "ill_geo2 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo2 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo3"), true);
- ok(0, "ill_geo3 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo3 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo4"), true);
- ok(0, "ill_geo4 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo4 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo5"), true);
- ok(0, "ill_geo5 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo5 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo6"), true);
- ok(0, "ill_geo6 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo6 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo7"), true);
- ok(0, "ill_geo7 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo7 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo8"), true);
- ok(0, "ill_geo8 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo8 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("ill_geo9"), true);
- ok(0, "ill_geo9 - should have been caught as invalid geo");
- } catch (ex) {
- ok(1, "ill_geo9 - caught invalid geo");
- }
- try {
- Geo = new geo(document.getElementById("zero_geo"), true);
- ok(1, "zero_geo - creation succeeded");
- } catch (ex) {
- ok(0, "zero_geo - creation failed");
- }
- try {
- Geo = new geo(document.getElementById("extra_geo"), true);
- ok(1, "extra_geo - creation succeeded");
- } catch (ex) {
- ok(0, "extra_geo - creation failed");
- }
-}
-
-
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_getters.html
+++ /dev/null
@@ -1,156 +0,0 @@
-<html>
-<head>
- <title>Testing Mixed Up Microformat APIs</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body id="contentbody">
- <pre id="test">
- <script class="testbody" type="text/javascript">
-
- // Called from onload in iframe
- function test_MicroformatsAPI() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- // Test that we can get them all
- var mfs = [];
- mfs = Microformats.get("adr",
- document.getElementById("content"),
- {showHidden: true});
-
- is(mfs.length, 2, "Two adr's in our array");
-
- mfs = Microformats.get("geo",
- document.getElementById("content"),
- {recurseExternalFrames: true});
- is(mfs.length, 3, "Three geo's in our array");
-
- mfs = Microformats.get("hCalendar",
- document.getElementById("content"),
- {recurseExternalFrames: false});
- // Should get the hCalendar whether we recurseExternalFrames or not.
- is(mfs.length, 2, "Two hCalendar returned not recursing frames");
-
- mfs = Microformats.get("hCalendar",
- document.getElementById("content"),
- {recurseExternalFrames: true});
- is(mfs.length, 2, "Two hCalendars returned recursing frames");
-
- mfs = Microformats.get("hCard",
- document.getElementById("content"),
- {recurseExternalFrames: true},
- mfs);
- is(mfs.length, 3, "Two hCalendars and one hCard");
-
- mfs = Microformats.get("hCalendar", document.getElementById("secondnode"));
-
- is(mfs[0].summary, "Pseudo Conference",
- "Make sure we get the proper hCalendar from the second level node");
- is(mfs.length, 1, "And we should only get one hCalendar not two from this node.");
- }
- </script>
- </pre>
- <div id="content">
- <!-- hCard -->
- <p class="vcard" id="23-abbr-title-everything">
- <!-- perhaps the most annoying test ever -->
- <abbr class="fn" title="John Doe">foo</abbr>
- <span class="n">
- <abbr class="honorific-prefix" title="Mister">Mr.</abbr>
- <abbr class="given-name" title="Jonathan">John</abbr>
- <abbr class="additional-name" title="John">J</abbr>
- <abbr class="family-name" title="Doe-Smith">Doe</abbr>
- <abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
- </span>
- <abbr class="nickname" title="JJ">jj</abbr>
- <abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
- <span class="adr">
- <abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
- <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
- <abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
- <abbr class="locality" title="San Francisco">San Fran</abbr>
- <abbr class="region" title="California">CA</abbr>
- <abbr class="postal-code" title="12345-6789">12345</abbr>
- <abbr class="country-name" title="United States of America">USA</abbr>
- <abbr class="type" title="work">workplace</abbr>
- </span>
- <abbr class="tel" title="415.555.1234">1234</abbr>
- <abbr class="tel-type-value" title="work">workplace</abbr>
- <!-- mailer -->
- <abbr class="tz" title="-0700">Pacific Time</abbr>
- <span class="geo">
- <abbr class="latitude" title="37.77">Northern</abbr>
- <abbr class="longitude" title="-122.41">California</abbr>
- </span>
- <abbr class="title" title="President">pres.</abbr> and
- <abbr class="role" title="Chief">cat wrangler</abbr>
- <!-- <span class="agent"></span> -->
- <span class="org">
- <abbr class="organization-name" title="Intellicorp">foo</abbr>
- <abbr class="organization-unit" title="Intelligence">bar</abbr>
- </span>
- <!-- <abbr class="category" title=""></abbr> -->
- <abbr class="note" title="this is a note">this is not a note</abbr>
- <!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
- <!-- <abbr class="sort-string" title=""></abbr> -->
- <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
- <abbr class="class" title="public">pub</abbr>
- <!-- <abbr class="key" title=""></abbr> -->
- </p>
-
- <!-- hCalendar -->
- <frameset>
- <frame id="frame1">
- <div>
- <span class="notAMicroformat" id="notme">
- <abbr> class="foo">I am not a microformat</abbr>
- <abbr> class="title">Foolish title, not a format</abbr>
- </span>
- </div>
- </frame>
- <frame id="frame3">
- <span class="geo" id="02-geo-abbr-latlong" >
- <abbr class="latitude" title="75.77">Far Northern</abbr>
- <abbr class="longitude" title="-122.41">Canada</abbr>
- </span>
- <frame id="frame2">
- <div class="vcalendar">
- <span class="vevent" id="15-calendar-xml-lang">
- <a class="url" href="http://www.web2con.com/">
- <span class="summary">Web 2.0 Conference</span>:
- <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
- </frame>
- </frameset>
-
- <div id="secondnode">
- <span>some interesting content</span>
-
- <!-- Geo Fire test once we know this is loaded.-->
- <iframe src="geo.html" onload="test_MicroformatsAPI();">
- </iframe>
-
- <!-- adr -->
- <div class="adr" id="01-extended-address">
- <span class="extended-address">Park Bench</span>
- </div>
-
- <div class="vcalendar">
- <span class="vevent" id="16-calendar-xml-lang">
- <a class="url" href="http://www.foo.com/">
- <span class="summary">Pseudo Conference</span>:
- <abbr class="dtstart" title="2008-04-01">April 1</abbr>-
- <abbr class="dtend" title="2008-04-03">April 3</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
- </div>
- </div>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_hCalendar.html
+++ /dev/null
@@ -1,306 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title>Testing Microformats.js (hCalendar)</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body>
-<div id="content" style="display: none">
-
- From http://hg.microformats.org/tests
-
- <div class="vevent" id="01-component-vevent-dtstart-date">
- <div>Dates: <abbr class="dtstart" title="19970903">September 3, 1997</abbr></div>
- </div>
-
- <div class="vevent" id="02-component-vevent-dtstart-datetime">
- <div>Dates: <abbr class="dtstart" title="19970903T163000Z">September 3, 1997, 16:30</abbr></div>
- </div>
-
- <div class="vevent" id="03-component-vevent-dtend-date">
- <div>Dates: <abbr class="dtstart" title="19970903">September 3, 1997</abbr>
- <abbr class="dtend" title="19970904">( all day )</abbr></div>
- </div>
-
- <div class="vevent" id="04-component-vevent-dtend-datetime">
- <div>Date: <abbr class="dtstart" title="19970903T160000Z">September 3, 1997 at 4pm</abbr>
- <abbr class="dtend" title="19970903T180000Z"> for 2 hours.</abbr></div>
- </div>
-
- <div class="vcalendar">
- <span class="vevent" id="05-calendar-simple">
- <a class="url" href="http://www.web2con.com/">
- <span class="summary">Web 2.0 Conference</span>:
- <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
-
- <p class="vevent" id="06-component-vevent-uri-relative">
- <a class="url summary" href="/squidlist/calendar/12279/2006/1/15">Bad Movie Night - Gigli (blame mike spiegelman)</a>
- <br />
- <abbr class="dtstart" title="20060115T000000">Sun, Jan 15 : 8pm</abbr>
- <br />
- </p>
-
- <div class="vevent" id="07-component-vevent-description-simple">
- <div class="description">Project xyz Review Meeting Minutes</div>
- </div>
-
- <div class="aaa vevent" id="08-component-vevent-multiple-classes">
- <a class="bbb url" href="http://www.web2con.com/">
- <span class="ccc summary">Web 2.0 Conference</span>:
- <abbr class="ddd dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="eee dtend" title="2005-10-08">7</abbr>,
- at the <span class="fff location">Argent Hotel, San Francisco, CA</span>
- </a>
- </div>
-
- <ul>
- <li class="vevent" id="09-component-vevent-summary-in-img-alt">
- <a class="url" href="http://conferences.oreillynet.com/et2006/">
- <img style="display:block" class="summary"
- src="http://mochi.test:8888/tests/browser/microformats/test/picture.png"
- alt="O'Reilly Emerging Technology Conference" />
- <abbr class="dtstart" title="20060306">
- 3/6</abbr>-<abbr class="dtend" title="20060310">9</abbr>
- @
- <span class="location">
- Manchester Grand Hyatt in San Diego, CA
- </span>
- </a>
- </li>
- </ul>
-
- <div class="vcalendar">
- <div class="vevent" id="10-component-vevent-entity">
- <div class="summary">Cricket & Tennis Centre</div>
- <div class="description">Melbourne's Cricket & Tennis Centres are in the heart of the city</div>
- </div>
- </div>
-
- <p class="schedule vevent" id="11-component-vevent-summary-in-subelements">
- <span class="summary">
- <span style="font-weight:bold; color: #3E4876;">Welcome!</span>
- <a href="/cs/web2005/view/e_spkr/1852">John Battelle</a>,
- <a href="/cs/web2005/view/e_spkr/416">Tim O'Reilly</a>
- </span>
- <br />
- <b>Time:</b>
- <abbr class="dtstart" title="20051005T1630-0700">4:30pm</abbr>-
- <abbr class="dtend" title="20051005T1645-0700">4:45pm
- </abbr>
- </p>
-
- <p class="vevent" id="12-component-vevent-summary-url-in-same-class">
- <a class="url summary" href="http://www.laughingsquid.com/squidlist/calendar/12377/2006/1/25">Art Reception for Tom Schultz and Felix Macnee</a>
- <br />
- <abbr class="dtstart" title="20060125T000000">Wed, Jan 25 : 6:00 pm - 9:00 pm</abbr>
- <br />
- </p>
-
- <div class="vcalendar">
- <div class="vevent" id="13-component-vevent-summary-url-property">
- <span class="summary">
- <a class="url" href="http://dps1.travelocity.com/dparcobrand.ctl?smls=Y&Service=YHOE&.intl=us&aln_name=AA&flt_num=1655&dep_arp_name=&arr_arp_name=&dep_dt_dy_1=23&dep_dt_mn_1=Jan&dep_dt_yr_1=2006&dep_tm_1=9:00am">ORD-SFO/AA 1655</a>
- </span>
- </div>
- </div>
-
- <div class="vcalendar">
- <span class="vevent" id="15-calendar-xml-lang">
- <a class="url" href="http://www.web2con.com/">
- <span class="summary">Web 2.0 Conference</span>:
- <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
-
- <div class="vcalendar">
- <span class="vevent" id="16-calendar-force-outlook">
- <a class="url" href="http://www.web2con.com/">
- <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
-
- <p class="vevent" id="17-component-vevent-description-value-in-subelements">
- <span class="description">
- RESOLUTION: to have a
- <b class="summary">3rd PAW ftf meeting</b>
- <abbr class="dtstart" title="2006-01-18">18</abbr>-<abbr class="dtend" title="2006-01-20">19 Jan</abbr> in
- <em class="location">Maryland</em>; location contingent on confirmation from timbl</span>
- </p>
-
- <div class="vevent" id="18-component-vevent-uid.1">
- <div>UID: <span class="uid">http://example.com/foo.html</span></div>
- </div>
- <div class="vevent" id="18-component-vevent-uid.2">
- UID: <a class="uid" href="http://example.com/foo.html">another hcal event</a>
- </div>
-
- <div class="vevent" id="18-component-vevent-uid.3">
- UID: <object class="uid" data="http://example.com/foo.html">another hcal event</object>
- </div>
-
- <div class="vevent" id="18-component-vevent-uid.4">
- UID: <map id="foo"><area alt="uid" class="uid" href="http://example.com/foo.html" /></map>
- </div>
-
- <div class="vevent" id="18-component-vevent-uid.5">
- UID: <img class="uid" alt="uid" src="http://example.com/foo.html" />
- </div>
-
- <div class="vcalendar">
- <div class="vevent" id="19-calendar-attachments">
- <div>Start Time: <abbr class="dtstart" title="19970324T123000Z">March 24, 1997 12:30 UTC</abbr></div>
- <div class="summary">Calendaring Interoperability Planning Meeting</div>
-
- <div>Attachments:
- <ul>
- <li><a class="attach" href="http://microformats.org/img/logo.gif">microformats logo</a></li>
- <li><a class="attach" type="application/postscript" href="ftp://xyzCorp.com/pub/conf/bkgrnd.ps">ftp://xyzCorp.com/pub/conf/bkgrnd.ps</a></li>
- </ul>
- </div>
- </div>
- </div>
-
- <div class="vevent" id="empty-description">
- <span class="description"></span>
- </div>
-
-
-</div>
-
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-test_Microformats();
-test_hCard();
-
-function test_Microformats() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- ok(Microformats, "Check global access to Microformats");
-}
-
-function test_hCard() {
- var hCalendar = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").hCalendar;
-
- var hcalendar;
-
- hcalendar = new hCalendar(document.getElementById("01-component-vevent-dtstart-date"));
-
- is(hcalendar.dtstart, "1997-09-03", "01-component-vevent-dtstart-date - dtstart");
-
- hcalendar = new hCalendar(document.getElementById("02-component-vevent-dtstart-datetime"));
-
- is(hcalendar.dtstart, "1997-09-03T16:30:00Z", "02-component-vevent-dtstart-datetime - dtstart");
-
- hcalendar = new hCalendar(document.getElementById("03-component-vevent-dtend-date"));
-
- is(hcalendar.dtstart, "1997-09-03", "03-component-vevent-dtend-date - dtstart");
- is(hcalendar.dtend, "1997-09-04", "03-component-vevent-dtend-date - dtend");
-
-
- hcalendar = new hCalendar(document.getElementById("04-component-vevent-dtend-datetime"));
-
- is(hcalendar.dtstart, "1997-09-03T16:00:00Z", "04-component-vevent-dtend-datetime - dtstart");
- is(hcalendar.dtend, "1997-09-03T18:00:00Z", "04-component-vevent-dtend-datetime - dtend");
-
- hcalendar = new hCalendar(document.getElementById("05-calendar-simple"));
-
- is(hcalendar.dtstart, "2005-10-05", "05-calendar-simple - dtstart");
- is(hcalendar.dtend, "2005-10-08", "05-calendar-simple - dtend");
- is(hcalendar.url, "http://www.web2con.com/", "05-calendar-simple - url");
- is(hcalendar.summary, "Web 2.0 Conference", "05-calendar-simple - summary");
- is(hcalendar.location, "Argent Hotel, San Francisco, CA", "05-calendar-simple - location");
-
- hcalendar = new hCalendar(document.getElementById("06-component-vevent-uri-relative"));
- is(hcalendar.url, "http://mochi.test:8888/squidlist/calendar/12279/2006/1/15", "06-component-vevent-uri-relative - url");
- is(hcalendar.summary, "Bad Movie Night - Gigli (blame mike spiegelman)", "06-component-vevent-uri-relative - summary");
- is(hcalendar.dtstart, "2006-01-15T00:00:00", "06-component-vevent-uri-relative - dtstart");
-
- hcalendar = new hCalendar(document.getElementById("07-component-vevent-description-simple"));
- is(String(hcalendar.description), "Project xyz Review Meeting Minutes", "07-component-vevent-description-simple - description");
-
- hcalendar = new hCalendar(document.getElementById("08-component-vevent-multiple-classes"));
- is(hcalendar.dtstart, "2005-10-05", "08-component-vevent-multiple-classes - dtstart");
- is(hcalendar.dtend, "2005-10-08", "08-component-vevent-multiple-classes - dtend");
- is(hcalendar.url, "http://www.web2con.com/", "08-component-vevent-multiple-classes - url");
- is(hcalendar.summary, "Web 2.0 Conference", "08-component-vevent-multiple-classes - summary");
- is(hcalendar.location, "Argent Hotel, San Francisco, CA", "08-component-vevent-multiple-classes - location");
-
- hcalendar = new hCalendar(document.getElementById("09-component-vevent-summary-in-img-alt"));
- is(hcalendar.dtstart, "2006-03-06", "09-component-vevent-summary-in-img-alt - dtstart");
- is(hcalendar.dtend, "2006-03-10", "09-component-vevent-summary-in-img-alt - dtend");
- is(hcalendar.url, "http://conferences.oreillynet.com/et2006/", "09-component-vevent-summary-in-img-alt - url");
- is(hcalendar.summary, "O'Reilly Emerging Technology Conference", "09-component-vevent-summary-in-img-alt - summary");
- is(hcalendar.location, "Manchester Grand Hyatt in San Diego, CA", "09-component-vevent-summary-in-img-alt - location");
-
- hcalendar = new hCalendar(document.getElementById("10-component-vevent-entity"));
- is(hcalendar.summary, "Cricket & Tennis Centre", "10-component-vevent-entity - summary");
- is(String(hcalendar.description), "Melbourne's Cricket & Tennis Centres are in the heart of the city", "10-component-vevent-entity - description");
-
- hcalendar = new hCalendar(document.getElementById("11-component-vevent-summary-in-subelements"));
- is(hcalendar.dtstart, "2005-10-05T16:30:00-0700", "11-component-vevent-summary-in-subelements - dtstart");
- is(hcalendar.dtend, "2005-10-05T16:45:00-0700", "11-component-vevent-summary-in-subelements - dtend");
- is(hcalendar.summary, "Welcome! John Battelle, Tim O'Reilly", "11-component-vevent-summary-in-subelements - summary");
-
- hcalendar = new hCalendar(document.getElementById("12-component-vevent-summary-url-in-same-class"));
- is(hcalendar.dtstart, "2006-01-25T00:00:00", "12-component-vevent-summary-url-in-same-class - dtstart");
- is(hcalendar.summary, "Art Reception for Tom Schultz and Felix Macnee", "12-component-vevent-summary-url-in-same-class - summary");
- is(hcalendar.url, "http://www.laughingsquid.com/squidlist/calendar/12377/2006/1/25", "12-component-vevent-summary-url-in-same-class - url");
-
- hcalendar = new hCalendar(document.getElementById("13-component-vevent-summary-url-property"));
- is(hcalendar.summary, "ORD-SFO/AA 1655", "13-component-vevent-summary-url-property - summary");
- is(hcalendar.url, "http://dps1.travelocity.com/dparcobrand.ctl?smls=Y&Service=YHOE&.intl=us&aln_name=AA&flt_num=1655&dep_arp_name=&arr_arp_name=&dep_dt_dy_1=23&dep_dt_mn_1=Jan&dep_dt_yr_1=2006&dep_tm_1=9:00am", "13-component-vevent-summary-url-property - url");
-
- hcalendar = new hCalendar(document.getElementById("15-calendar-xml-lang"));
- is(hcalendar.dtend, "2005-10-08", "15-calendar-xml-lang - dtend");
- is(hcalendar.dtstart, "2005-10-05", "15-calendar-xml-lang - dtstart");
- is(hcalendar.location, "Argent Hotel, San Francisco, CA", "15-calendar-xml-lang - location");
- is(hcalendar.summary, "Web 2.0 Conference", "15-calendar-xml-lang - summary");
- is(hcalendar.url, "http://www.web2con.com/", "15-calendar-xml-lang - url");
-
- hcalendar = new hCalendar(document.getElementById("16-calendar-force-outlook"));
- is(hcalendar.dtend, "2005-10-08", "16-calendar-force-outlook - dtend");
- is(hcalendar.dtstart, "2005-10-05", "16-calendar-force-outlook - dtstart");
- is(hcalendar.location, "Argent Hotel, San Francisco, CA", "16-calendar-force-outlook - location");
- is(hcalendar.url, "http://www.web2con.com/", "16-calendar-force-outlook - url");
-
- hcalendar = new hCalendar(document.getElementById("17-component-vevent-description-value-in-subelements"));
- is(String(hcalendar.description), "RESOLUTION: to have a 3rd PAW ftf meeting 18-19 Jan in Maryland; location contingent on confirmation from timbl", "17-component-vevent-description-value-in-subelements - description");
- is(hcalendar.dtstart, "2006-01-18", "17-component-vevent-description-value-in-subelements - dtstart");
- is(hcalendar.dtend, "2006-01-20", "17-component-vevent-description-value-in-subelements - dtend");
- is(hcalendar.location, "Maryland", "17-component-vevent-description-value-in-subelements - location");
- is(hcalendar.summary, "3rd PAW ftf meeting", "17-component-vevent-description-value-in-subelements - summary");
-
- hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.1"));
-
- hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.2"));
-
- hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.3"));
-
- hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.4"));
-
- hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.5"));
-
- hcalendar = new hCalendar(document.getElementById("19-calendar-attachments"));
-
- hcalendar = new hCalendar(document.getElementById("empty-description"));
- is(String(hcalendar.description), "", "Empty description");
-}
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_hCard.html
+++ /dev/null
@@ -1,1176 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title>Testing Microformats.js (hCard)</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body>
-<div id="content" style="display: none">
-
- From http://microformats.org/tests/hcard/
-
- <div class="vcard" id="01-tantek-basic">
- <a class="url fn" href="http://tantek.com/">Tantek Çelik</a>
- <div class="org">Technorati</div>
- </div>
-
- <div class="vcard" id="02-multiple-class-names-on-vcard.1"><span class="fn n"><span class="given-name">Ryan</span> <span class="family-name">King</span></span></div>
- <p><span class="attendee vcard" id="02-multiple-class-names-on-vcard.2"><span class="fn n"><span class="given-name">Ryan</span> <span class="family-name">King</span></span></span></p>
- <address class="vcard author" id="02-multiple-class-names-on-vcard.3"><span class="fn n"><span class="given-name">Ryan</span> <span class="family-name">King</span></span></address>
- <ul><li class="reviewer vcard first" id="02-multiple-class-names-on-vcard.4"><span class="fn n"><span class="given-name">Ryan</span> <span class="family-name">King</span></span></li></ul>
-
- <p class="vcard" id="03-implied-n.1">
- <span class="fn">Ryan King</span>
- </p>
- <p class="vcard" id="03-implied-n.2">
- <abbr class="fn" title="Ryan King">me</abbr>
- </p>
- <p class="vcard" id="03-implied-n.3">
- <img src="/me.jpg" title="Brian Suda" alt="Ryan King" class="fn" />
- </p>
- <p class="vcard" id="03-implied-n.4">
- <a class="fn" href="http://suda.co.uk/">Brian Suda</a>
- </p>
- <p class="vcard" id="03-implied-n.5">
- <span class="fn">King, Ryan</span>
- </p>
- <p class="vcard" id="03-implied-n.6">
- <span class="fn">King, R</span>
- </p>
- <p class="vcard" id="03-implied-n.7">
- <span class="fn">King R</span>
- </p>
- <p class="vcard" id="03-implied-n.8">
- <span class="fn">King R.</span>
- </p>
- <p class="vcard" id="03-implied-n.9">
- <span class="fn">Jesse James Garrett</span>
- </p>
- <p class="vcard" id="03-implied-n.10">
- <span class="fn">Thomas Vander Wal</span>
- </p>
-
- <p class="vcard" id="04-ignore-unknowns">
- <span class="ignore-me">Some text that shouldn't be in the vCard.</span>
- <span class="fn n">
- <span class="given-name">Ryan</span> <span class="family-name">King</span>
- </span>
- </p>
- <p class="ignore-me-too">Some more text that shouldn't be in the vCard.</p>
-
- <p class="vcard" id="05-mailto-1">
- <!-- fn should be the text node (with implied-n-optimization) and 'email' should be the href, sans scheme -->
- <a class="fn email" href="mailto:ryan@technorati.com">Ryan King</a>
- </p>
-
- <p class="vcard" id="06-mailto-2">
- <!-- ignore the parameters on the addr-spec -->
- <a class="fn email" href="mailto:brian@example.com?subject=foo">Brian Suda</a>
- </p>
-
- <p class="vcard" id="07-relative-url">
- <span class="fn n"><span class="given-name">John</span> <span class="family-name">Doe</span></span>
- <a class="url" href="/home/blah">my website</a>
- </p>
-
- Tests 8/9/10 involve base tags and must each be self contained
-
- <p class="vcard" id="11-multiple-urls">
- <span class="fn n">
- <span class="given-name">John</span> <span class="family-name">Doe</span></span>
- <a class="url" href="http://example.com/foo">my website</a>
- <a class="url" href="http://example.com/bar">my other website</a>
- </p>
-
- <p class="vcard" id="12-img-src-url">
- <span class="fn n"><span class="given-name">John</span> <span class="family-name">Doe</span></span>
- <!-- take the @src, ignore the @type -->
- <img class="url" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" type="image/png" />
- </p>
-
- <p class="vcard" id="13-photo-logo">
- <span class="fn n"><span class="given-name">John</span> <span class="family-name">Doe</span></span>
- <!-- take the @src, ignore the @type -->
- <img class="photo logo" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" type="image/png" />
- </p>
-
- <p class="vcard" id="14-img-src-data-url">
- <span class="fn n"><span class="given-name">John</span> <span class="family-name">Doe</span></span>
- <img class="photo logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg=="/>
- </p>
-
- <p class="vcard" id="15-honorific-additional-single">
- <span class="fn n">
- <span class="honorific-prefix">Mr.</span>
- <span class="given-name">John</span>
- <span class="additional-name">Maurice</span>
- <span class="family-name">Doe</span>,
- <span class="honorific-suffix">Ph.D.</span>
- </span>
- </p>
-
- <p class="vcard" id="16-honorific-additional-multiple">
- <span class="fn n">
- <span class="honorific-prefix">Mr.</span>
- <span class="honorific-prefix">Dr.</span>
- <span class="given-name">John</span>
- <span class="additional-name">Maurice</span>
- <span class="additional-name">Benjamin</span>
- <span class="family-name">Doe</span>
- <span class="honorific-suffix">Ph.D.</span>,
- <span class="honorific-suffix">J.D.</span>
- </span>
- </p>
-
- <p class="vcard" id="17-email-not-uri">
- <span class="fn">John Doe</span>
- <span class="email">john@example.com</span>
- </p>
-
- <p class="vcard" id="18-object-data-http-uri">
- <span class="fn">John Doe</span>
- <object class="url photo logo" data="http://mochi.test:8888/tests/browser/microformats/test/picture.png" type="image/png"></object>
- </p>
-
- <p class="vcard" id="19-object-data-data-uri">
- <span class="fn">John Doe</span>
- <object class="photo logo" data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg==" />
- </p>
-
- <p class="vcard" id="20-image-alt">
-<!-- only testing 'fn' here, but you should be able to parse any text value out of the img@alt -->
-<!-- also note, the fn should only be used to infer n, when there's no explicit n in the hcard -->
- <img class="fn photo logo" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" alt="John Doe" />
- </p>
-
- <div class="vcard" id="21-tel">
- <p class="fn">John Doe</p>v
- <p class="tel">+1.415.555.1231</p>
- <p class="tel">
- <span class="type">home</span>
- <span class="value">+1 415 555 1232</span>
- </p>
- <div class="tel">
- types:
- <ul>
- <li class="type">msg</li>
- <li class="type">home</li>
- <li class="type">work</li>
- <li class="type">pref</li>
- <li class="type">voice</li>
- <li class="type">fax</li>
- <li class="type">cell</li>
- <li class="type">video</li>
- <li class="type">pager</li>
- <li class="type">bbs</li>
- <li class="type">car</li>
- <li class="type">isdn</li>
- <li class="type">pcs</li>
- <li class="type">invalid</li>
- </ul>
- <span class="value">+1</span>
- <span class="value">415</span>
- <span class="value">555</span>
- <span class="value">1233</span>
- </div>
- <p class="tel">
- <abbr class="type" title="home">H</abbr>
- <span class="value">+1 415 555 1234</span>
- </p>
- <a class="tel" href="tel:+1.415.555.1235">call me</a>
- <object class="tel" data="tel:+1.415.555.1236">call me</object>
- <a class="tel" href="fax:+1.415.555.1238">call me</a>
- <object class="tel" data="fax:+1.415.555.1239">call me</object>
- <a class="tel" href="modem:+1.415.555.1241">call me</a>
- <object class="tel" data="modem:+1.415.555.1242">call me</object>
- </div>
-
- <div class="vcard" id="21-tel.2">
- <span class="fn">John Doe</span>
- <span class="tel"><span class="type">Home</span> +1.415.555.1212</span>
- </div>
-
- <div class="vcard" id="21-tel.3">
- <span class="fn">John Doe</span>
- <span class="tel"><span class="type">Home</span><span class="type"> Pref</span> +1.415.555.1212</span>
- </div>
-
- <!-- TODO: add test for 'extended' -->
- <div class="vcard" id="22-adr">
- <p class="fn">John Doe</p>
- <p class="adr">
- <span class="street-address">1231 Main St.</span>
- <span class="locality">Beverly Hills</span>
- <span class="region">California</span>
- <span class="country-name">United States of America</span>
- <span class="postal-code">90210</span>
- </p>
-<!-- multiple street-addresses, should produce a comma-separated list -->
- <p class="adr">
- <span class="post-office-box">PO Box 1234</span>
- <span class="street-address">1232 Main St.</span>
- <span class="street-address">Suite 100</span>
- <span class="locality">Beverly Hills</span>
- <span class="region">California</span>
- <span class="country-name">United States of America</span>
- <span class="postal-code">90210</span>
- </p>
-<!-- one type subproperty -->
- <p class="adr">
- <span class="type">home</span>
- <span class="street-address">1233 Main St.</span>
- <span class="locality">Beverly Hills</span>
- <span class="region">California</span>
- <span class="country-name">United States of America</span>
- <span class="postal-code">90210</span>
- </p>
-<!-- many type subproperties, each with their own class name -->
- <div class="adr">
- <ul>
- <li class="type">dom</li>
- <li class="type">intl</li>
- <li class="type">postal</li>
- <li class="type">parcel</li>
- <li class="type">home</li>
- <li class="type">work</li>
- <li class="type">pref</li>
- </ul>
- <span class="street-address">1234 Main St.</span>
- <span class="locality">Beverly Hills</span>
- <span class="region">California</span>
- <span class="country-name">United States of America</span>
- <span class="postal-code">90210</span>
- </div>
- </div>
-
- <p class="vcard" id="23-abbr-title-everything">
-<!-- perhaps the most annoying test ever -->
- <abbr class="fn" title="John Doe">foo</abbr>
- <span class="n">
- <abbr class="honorific-prefix" title="Mister">Mr.</abbr>
- <abbr class="given-name" title="Jonathan">John</abbr>
- <abbr class="additional-name" title="John">J</abbr>
- <abbr class="family-name" title="Doe-Smith">Doe</abbr>
- <abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
- </span>
- <abbr class="nickname" title="JJ">jj</abbr>
- <abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
- <span class="adr">
- <abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
- <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
- <abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
- <abbr class="locality" title="San Francisco">San Fran</abbr>
- <abbr class="region" title="California">CA</abbr>
- <abbr class="postal-code" title="12345-6789">12345</abbr>
- <abbr class="country-name" title="United States of America">USA</abbr>
- <abbr class="type" title="work">workplace</abbr>
- </span>
- <abbr class="tel" title="415.555.1234">1234</abbr>
- <abbr class="tel-type-value" title="work">workplace</abbr>
-<!-- mailer -->
- <abbr class="tz" title="-0700">Pacific Time</abbr>
- <span class="geo">
- <abbr class="latitude" title="37.77">Northern</abbr>
- <abbr class="longitude" title="-122.41">California</abbr>
- </span>
- <abbr class="title" title="President">pres.</abbr> and
- <abbr class="role" title="Chief">cat wrangler</abbr>
-<!-- <span class="agent"></span> -->
- <span class="org">
- <abbr class="organization-name" title="Intellicorp">foo</abbr>
- <abbr class="organization-unit" title="Intelligence">bar</abbr>
- </span>
-<!-- <abbr class="category" title=""></abbr> -->
- <abbr class="note" title="this is a note">this is not a note</abbr>
-<!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
-<!-- <abbr class="sort-string" title=""></abbr> -->
- <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
- <abbr class="class" title="public">pub</abbr>
-<!-- <abbr class="key" title=""></abbr> -->
- </p>
-
- There is no 24
-
- <p class="vcard" id="25-geo-abbr">
- <abbr class="geo" title="30.267991;-97.739568"><span class="fn org">Paradise</span></abbr>
- </p>
-
-<!-- This test is to make sure that parsers look at ancestors, not just children.-->
- <div class="vcard" id="26-ancestors">
- <!-- perhaps the second most annoying test ever -->
- <div>
- <span class="fn"><span>John</span> <span>Doe</span></span>
- <span class="n">
- <span>
- <span class="honorific-prefix"><strong>Mister</strong></span>
- <span class="given-name"><i>Jonathan</i></span>
- <span class="additional-name"><b>John</b></span>
- <span class="family-name"><em>Doe-Smith</em></span>
- <span class="honorific-suffix">Medical Doctor</span>
- </span>
- </span>
- <span class="nickname"><span>JJ</span></span>
- <span class="bday">2006-04-04</span>
- <span class="adr">
- <span>
- <span class="post-office-box"><samp>Box 1234</samp></span>
- <span class="extended-address"><dfn>Suite 100</dfn></span>
- <span class="street-address"><span>123 Fake Street</span></span>
- <span class="locality"><em>San Francisco</em></span>
- <span class="region"><strong>California</strong></span>
- <span class="postal-code"><abbr>12345-6789</abbr></span>
- <span class="country-name"><acronym>United States of America</acronym></span>
- <span class="type"><span>work</span></span>
- </span>
- </span>
- <span class="tel"><span>415</span>.<span>555</span>.<span>1234</span></span>
- <span class="tel-type-value">work</span>
- <!-- @TODO mailer? -->
- <span class="tz"><span>-0700</span></span>
- <span class="geo">
- <span>
- <span class="latitude"><code>37.77</code></span>
- <span class="longitude"><tt>-122.41</tt></span>
- </span>
- </span>
- <span class="title"><strong>President</strong></span> and
- <span class="role"><em>Chief</em></span>
- <span class="agent vcard">
- <span class="fn">Bob Smith</span>
- <span class="title">Executive Assistant</span>
- </span>
- <!-- <span class="agent</span> @TODO -->
- <span class="org">
- <span class="organization-name"><strong>Intellicorp</strong></span>
- <span class="organization-unit"><em>Intelligence</em></span>
- </span>
- <!-- @TODO <span class="category"></span> -->
- <span class="note"><cite>this is a note</cite></span>
- <!-- @TODO <span class="rev"></span> (revision datetime) -->
- <!-- @TODO <span class="sort-string"></span> -->
- <span class="uid"><kbd>abcdefghijklmnopqrstuvwxyz</kbd></span>
- <span class="class"><samp>public</samp></span>
- <!-- @TODO <span class="key"></span> -->
- </div>
- </div>
-
- <p class="vcard" id="27-bday-date">
- <span class="fn">john doe</span>,
- <abbr class="bday" title="2000-01-01">January 1st, 2000</abbr>
- </p>
-
- <p class="vcard" id="28-bday-datetime">
- <span class="fn">john doe</span>,
- <abbr class="bday" title="2000-01-01T00:00:00">January 1st, 2000 at midnight</abbr>
- </p>
-
- <p class="vcard" id="29-bday-datetime-timezone">
- <span class="fn">john doe</span>,
- <abbr class="bday" title="2000-01-01T00:00:00-0800">January 1st, 2000 at midnight on the north american west coast</abbr>
- </p>
-
- <div class="vcard" id="30-fn-org.1">
- <div class="fn org">W3C</div>
- </div>
- <div class="vcard" id="30-fn-org.2">
- <div class="fn">Dan Connolly</div>
- <div class="org">W3C</div>
- </div>
- <div class="vcard" id="30-fn-org.3">
- <img class="fn" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" alt="W3C" />
- <div class="org">W3C</div>
- </div>
- <div class="vcard" id="30-fn-org.4">
- <img class="fn org" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png"
- alt="World Wide Web Consortium" />
- </div>
- <div class="vcard" id="30-fn-org.5">
- <object data="http://mochi.test:8888/tests/browser/microformats/test/w3c_home">
- <abbr class="fn org" title="World Wide Web Consortium">W3C</abbr>
- </object>
- </div>
-
- <p id="email1"><a href="mailto:correct@example.com" class="email">my email</a></p>
- <p id="email2"><a href="mailto:incorrect@example.com" class="email">my email</a></p>
- <div class="vcard" id="31-include.1">
- <a class="url fn" href="http://suda.co.uk/">Brian Suda</a>
- <object data="#email1" class="include" type="text/html"/>
- <object data="#email2" type="text/html"/>
- </div>
- <div class="vcard" id="31-include.2">
- <a class="url fn" href="http://suda.co.uk/">Brian Suda</a>
- <a href="#email1" class="include"></a>
- <a href="#email2"/>
- </div>
- <div class="vcard" id="31-include.3">
- <a class="url fn" href="http://suda.co.uk/">Brian Suda</a>
- <a href="#email1" class="include"/>
- <a href="#email2"/>
- </div>
- <div class="vcard" id="31-include.4">
- <a class="url fn" href="http://suda.co.uk/">Brian Suda</a>
- <a href="#email" class="include"/>
- </div>
-
- <table>
- <tr>
- <th id="org" ><a class="url org" href="http://example.org/">example.org</a></th>
- </tr>
- <tr>
- <td class="vcard" id="32-header.1" headers="org"><span class="fn">Brian Suda</span></td>
- </tr>
- <tr>
- <td class="vcard" id="32-header.2" headers="org"><span class="fn">John Doe</span></td>
- </tr>
- </table>
-
- <div class="vcard" id="33-area.1">
- <map id="mailto-test-1">
- <area class="fn email" href="mailto:joe@example.com" alt="Joe Public"/>
- <area class="url" href="http://example.com/" alt="my website!" />
- </map>
- </div>
- <div class="vcard" id="33-area.2">
- <map id="mailto-test-2">
- <area class="fn email" href="mailto:joe@example.com" alt="Joe Public"/>
- <area class="url" href="http://example.com/" alt="my website!" />
- <area class="org" href="http://example.com/" alt="Joe Public" />
- </map>
- </div>
- <div class="vcard" id="33-area.3">
- <map id="mailto-test-3">
- <area class="fn email" href="mailto:joe@example.com" alt="Joe Public"/>
- <area class="url" href="http://example.com/" alt="my website!" />
- </map>
- <img class="org" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" alt="Joe Public" />
- </div>
- <div class="vcard" id="33-area.4">
- <map id="mailto-test-4">
- <area class="fn email" href="mailto:joe@example.com" alt="Joe Public"/>
- <area class="url" href="http://example.com/" alt="my website!" />
- </map>
- <div class="org">Joe Public</div>
- </div>
- <div class="vcard" id="33-area.5">
- <map id="mailto-test-5">
- <area class="fn email" href="mailto:joe@example.com" alt="Joe Public"/>
- <area class="url" href="http://example.com/" alt="my website!" />
- </map>
- <abbr class="org" title="Joe Public">Joe</abbr>
- </div>
-
- <div class="vcard" id="34-notes">
- <a class="fn email" href="mailto:joe@example.com">Joe Public</a>
- <span class="note">Note 1</span>
- <span class="foorbar">Note 2</span>
- <span class="note foorbar">Note 3</span>
- <span class="note foorbar">Note 4 with a ; and a , to be escaped<!-- this <strong>should</strong> be ignored--></span>
- </div>
-
- <div class="vcard" id="35-include-pattern.1">
- <span class="fn n" id="j">
- <span class="given-name">James</span> <span class="family-name">Levine</span>
- </span>
- </div>
- <div class="vcard" id="35-include-pattern.2">
- <object data="#j" class="include" type="text/html"></object>
- <span class="org">SimplyHired</span>
- <span class="title">Microformat Brainstormer</span>
- </div>
- <div class="vcard" id="35-include-pattern.3">
- <span class="fn n" id="j2">
- <span class="given-name">James</span> <span class="family-name">Levine</span>
- </span>
- <span class="org">SimplyHired</span>
- <span class="title">Microformat Brainstormer</span>
- </div>
-
- <p class="vcard" id="36-categories.1">
- <span class="fn">john doe</span>,
- <abbr class="category" title="C1">C1a</abbr>
- <a class="category" href="http://example.com" title="C2">C2a</a>
- <a class="category" href="http://example.com/C3" rel="tag" title="C3a">C3b</a>
- <img class="category" src="http://mochi.test:8888/tests/browser/microformats/test/picture.png" alt="C4"/>
- <a class="category" href="http://example.com/C5/" rel="tag" title="C5a">C5b</a>
- <a class="category" href="http://example.com/C6?tag=false" rel="tag" title="C6a">C6b</a>
- <a class="category" href="http://example.com/C7#anchor" rel="tag" title="C7a">C7b</a>
- <a class="category" href="http://example.com/C8?tag=trailing-slash/" rel="tag" title="C8a">C8b</a>
- <a class="category" href="http://example.com/C9/?tag=trailing-slash/" rel="tag" title="C9a">C9b</a>
- </p>
- <div class="vcard" id="36-categories.2">
- <span class="fn n">
- <span class="given-name">Joe</span> <span class="family-name">User</span>
- </span>
- <span class="category">User</span>
- <a class="category" rel="tag" href="http://example.com/luser">a big luser!</a>
- </div>
-
- <p class="vcard" id="37-singleton">
- <span class="fn n"><span class="given-name">john</span> <span class="family-name"><span class="sort-string">d</span>oe</span> 1</span>
- <span class="fn n"><span class="given-name"><span class="sort-string">j</span>ohn</span> <span class="family-name">doe</span> 2</span>
- <abbr class="bday" title="20060707">today</abbr>
- <abbr class="bday" title="20060708">tomorrow</abbr>
- <abbr class="geo" title="123.45;67.89">Here</abbr>
- <abbr class="geo" title="98.765;43.21">There</abbr>
- <abbr class="rev" title="20060707">today</abbr>
- <abbr class="rev" title="20060708">tomorrow</abbr>
- <abbr class="uid" title="unique-id-1">id-1</abbr>
- <abbr class="uid" title="unique-id-2">id-2</abbr>
- <span class="tz">+0600</span>
- <span class="tz">+0800</span>
- <span class="class">public</span>
- <span class="class">private</span>
- </p>
-
- <div class="vcard" id="38-uid.1">
- <span class="fn">Ryan King</span>
- <a class="url uid" href="http://theryanking.com/contact/">My other hCard</a>
- </div>
- <div class="vcard" id="38-uid.2">
- <span class="fn">Ryan King</span>
- <object class="url uid" data="http://mochi.test:8888/tests/browser/microformats/test/contact/">My other hCard</object>
- </div>
- <div class="vcard" id="38-uid.3">
- <span class="fn">Ryan King</span>
- <img class="url uid" src="http://mochi.test:8888/tests/browser/microformats/test/contact/" alt="my other hcard" />
- </div>
- <div class="vcard" id="38-uid.4">
- <span class="fn">Ryan King</span>
- <map id="foo"><area class="url uid" href="http://theryanking.com/contact/" alt="my other hcard" /></map>
- </div>
-
- <div class="vcard" id="39-noteHTML">
- <a class="fn">Joe Public</a>
- <span class="note"><b>Note</b></span>
- </div>
-
- <div class="vcard" id="email-type">
- <span class="fn">John Doe</span>
- <span class="email">
- <span class="type">internet</span>
- <a href="mailto:notthis@example.com">john@example.com</a>
- </span>
- </div>
-
-
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-test_Microformats();
-test_hCard();
-
-function test_Microformats() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- ok(Microformats, "Check global access to Microformats");
-}
-
-function test_hCard() {
- var hCard = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").hCard;
-
- var hcard;
-
- hcard = new hCard(document.getElementById("01-tantek-basic"));
-
- is(hcard.fn, "Tantek Çelik", "01-tantek-basic - fn");
- is(String(hcard.url), "http://tantek.com/", "01-tantek-basic - url");
- is(hcard.n["given-name"][0], "Tantek", "01-tantek-basic - given-name");
- is(hcard.n["family-name"][0], "Çelik", "01-tantek-basic - family-name");
- is(hcard.org[0]["organization-name"], "Technorati", "01-tantek-basic - organization-name");
-
- hcard = new hCard(document.getElementById("02-multiple-class-names-on-vcard.1"));
-
- is(hcard.fn, "Ryan King", "02-multiple-class-names-on-vcard.1 - fn");
- is(hcard.n["given-name"][0], "Ryan", "02-multiple-class-names-on-vcard.1 - given-name");
- is(hcard.n["family-name"][0], "King", "02-multiple-class-names-on-vcard.1 - family-name");
-
- hcard = new hCard(document.getElementById("02-multiple-class-names-on-vcard.2"));
-
- is(hcard.fn, "Ryan King", "02-multiple-class-names-on-vcard.2 - fn");
- is(hcard.n["given-name"][0], "Ryan", "02-multiple-class-names-on-vcard.2 - given-name");
- is(hcard.n["family-name"][0], "King", "02-multiple-class-names-on-vcard.2 - family-name");
-
- hcard = new hCard(document.getElementById("02-multiple-class-names-on-vcard.3"));
-
- is(hcard.fn, "Ryan King", "02-multiple-class-names-on-vcard.3 - fn");
- is(hcard.n["given-name"][0], "Ryan", "02-multiple-class-names-on-vcard.3 - given-name");
- is(hcard.n["family-name"][0], "King", "02-multiple-class-names-on-vcard.3 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.1"));
-
- is(hcard.fn, "Ryan King", "03-implied-n.1 - fn");
- is(hcard.n["given-name"][0], "Ryan", "03-implied-n.1 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.1 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.2"));
-
- is(hcard.fn, "Ryan King", "03-implied-n.2 - fn");
- is(hcard.n["given-name"][0], "Ryan", "03-implied-n.2 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.2 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.3"));
-
- is(hcard.fn, "Ryan King", "03-implied-n.3 - fn");
- is(hcard.n["given-name"][0], "Ryan", "03-implied-n.3 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.3 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.4"));
-
- is(hcard.fn, "Brian Suda", "03-implied-n.4 - fn");
- is(hcard.n["given-name"][0], "Brian", "03-implied-n.4 - given-name");
- is(hcard.n["family-name"][0], "Suda", "03-implied-n.4 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.5"));
-
- is(hcard.fn, "King, Ryan", "03-implied-n.5 - fn");
- is(hcard.n["given-name"][0], "Ryan", "03-implied-n.5 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.5 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.6"));
-
- is(hcard.fn, "King, R", "03-implied-n.6 - fn");
- is(hcard.n["given-name"][0], "R", "03-implied-n.6 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.6 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.7"));
-
- is(hcard.fn, "King R", "03-implied-n.7 - fn");
- is(hcard.n["given-name"][0], "R", "03-implied-n.7 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.7 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.8"));
-
- is(hcard.fn, "King R.", "03-implied-n.8 - fn");
- is(hcard.n["given-name"][0], "R.", "03-implied-n.8 - given-name");
- is(hcard.n["family-name"][0], "King", "03-implied-n.8 - family-name");
-
- hcard = new hCard(document.getElementById("03-implied-n.9"));
-
- is(hcard.fn, "Jesse James Garrett", "03-implied-n.9 - fn");
- ok(hcard.n === undefined, "03-implied-n.9 -n");
-
- hcard = new hCard(document.getElementById("03-implied-n.10"));
-
- is(hcard.fn, "Thomas Vander Wal", "03-implied-n.10 - fn");
- ok(hcard.n === undefined, "03-implied-n.10 -n");
-
- hcard = new hCard(document.getElementById("04-ignore-unknowns"));
-
- is(hcard.fn, "Ryan King", "04-ignore-unknowns - fn");
- is(hcard.n["given-name"][0], "Ryan", "04-ignore-unknowns - given-name");
- is(hcard.n["family-name"][0], "King", "04-ignore-unknowns - family-name");
-
- hcard = new hCard(document.getElementById("05-mailto-1"));
-
- is(hcard.fn, "Ryan King", "05-mailto-1 - fn");
- is(hcard.n["given-name"][0], "Ryan", "05-mailto-1 - given-name");
- is(hcard.n["family-name"][0], "King", "05-mailto-1 - family-name");
- is(hcard.email[0].value, "ryan@technorati.com", "05-mailto-1 - email");
-
- hcard = new hCard(document.getElementById("06-mailto-2"));
-
- is(hcard.fn, "Brian Suda", "06-mailto-2 - fn");
- is(hcard.n["given-name"][0], "Brian", "06-mailto-2 - given-name");
- is(hcard.n["family-name"][0], "Suda", "06-mailto-2 - family-name");
- is(hcard.email[0].value, "brian@example.com", "06-mailto-2 - email");
-
- hcard = new hCard(document.getElementById("07-relative-url"));
-
- is(hcard.fn, "John Doe", "07-relative-url - fn");
- is(hcard.n["given-name"][0], "John", "07-relative-url - given-name");
- is(hcard.n["family-name"][0], "Doe", "07-relative-url - family-name");
-// is(hcard.url[0], "http://microformats.org/home/blah", "07-relative-url - url");
- is(String(hcard.url), "http://mochi.test:8888/home/blah", "07-relative-url - url");
-
- hcard = new hCard(document.getElementById("11-multiple-urls"));
-
- is(hcard.fn, "John Doe", "11-multiple-urls - fn");
- is(hcard.n["given-name"][0], "John", "11-multiple-urls - given-name");
- is(hcard.n["family-name"][0], "Doe", "11-multiple-urls - family-name");
- is(hcard.url[0], "http://example.com/foo", "11-multiple-urls - url");
- is(hcard.url[1], "http://example.com/bar", "11-multiple-urls - url");
-
- hcard = new hCard(document.getElementById("12-img-src-url"));
-
- is(hcard.fn, "John Doe", "12-img-src-url - fn");
- is(hcard.n["given-name"][0], "John", "12-img-src-url - given-name");
- is(hcard.n["family-name"][0], "Doe", "12-img-src-url - family-name");
- is(hcard.url[0], "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "12-img-src-url - url");
-
- hcard = new hCard(document.getElementById("13-photo-logo"));
-
- is(hcard.fn, "John Doe", "13-photo-logo - fn");
- is(hcard.n["given-name"][0], "John", "13-photo-logo - given-name");
- is(hcard.n["family-name"][0], "Doe", "13-photo-logo - family-name");
- is(String(hcard.logo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "13-photo-logo - logo");
- is(String(hcard.photo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "13-photo-logo - photo");
-
- hcard = new hCard(document.getElementById("14-img-src-data-url"));
-
- is(hcard.fn, "John Doe", "14-img-src-data-url - fn");
- is(hcard.n["given-name"][0], "John", "14-img-src-data-url - given-name");
- is(hcard.n["family-name"][0], "Doe", "14-img-src-data-url - family-name");
- is(String(hcard.logo), "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg==", "14-img-src-data-url - logo");
- is(String(hcard.photo), "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg==", "14-img-src-data-url - photo");
-
- hcard = new hCard(document.getElementById("15-honorific-additional-single"));
-
- is(hcard.fn, "Mr. John Maurice Doe, Ph.D.", "15-honorific-additional-single - fn");
- is(hcard.n["given-name"][0], "John", "15-honorific-additional-single - given-name");
- is(hcard.n["family-name"][0], "Doe", "15-honorific-additional-single - family-name");
- is(String(hcard.n["honorific-prefix"]), "Mr.", "15-honorific-additional-single - honorific-prefix");
- is(String(hcard.n["additional-name"]), "Maurice", "15-honorific-additional-single - additional-name");
- is(String(hcard.n["honorific-suffix"]), "Ph.D.", "15-honorific-additional-single - honorific-suffix");
-
- hcard = new hCard(document.getElementById("16-honorific-additional-multiple"));
-
- is(hcard.fn, "Mr. Dr. John Maurice Benjamin Doe Ph.D., J.D.", "16-honorific-additional-multiple - fn");
- is(hcard.n["given-name"][0], "John", "16-honorific-additional-multiple - given-name");
- is(hcard.n["family-name"][0], "Doe", "16-honorific-additional-multiple - family-name");
- is(hcard.n["honorific-prefix"][0], "Mr.", "16-honorific-additional-multiple - honorific-prefix");
- is(hcard.n["honorific-prefix"][1], "Dr.", "16-honorific-additional-multiple - honorific-prefix");
- is(hcard.n["additional-name"][0], "Maurice", "16-honorific-additional-multiple - additional-name");
- is(hcard.n["additional-name"][1], "Benjamin", "16-honorific-additional-multiple - additional-name");
- is(hcard.n["honorific-suffix"][0], "Ph.D.", "16-honorific-additional-multiple - honorific-suffix");
- is(hcard.n["honorific-suffix"][1], "J.D.", "16-honorific-additional-multiple - honorific-suffix");
-
- hcard = new hCard(document.getElementById("17-email-not-uri"));
-
- is(hcard.fn, "John Doe", "17-email-not-uri - fn");
- is(hcard.n["given-name"][0], "John", "17-email-not-uri - given-name");
- is(hcard.n["family-name"][0], "Doe", "17-email-not-uri - family-name");
- is(hcard.email[0].value, "john@example.com", "17-email-not-uri - email");
-
- hcard = new hCard(document.getElementById("18-object-data-http-uri"));
-
- is(hcard.fn, "John Doe", "18-object-data-http-uri - fn");
- is(hcard.n["given-name"][0], "John", "18-object-data-http-uri - given-name");
- is(hcard.n["family-name"][0], "Doe", "18-object-data-http-uri - family-name");
- is(String(hcard.logo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "18-object-data-http-uri - logo");
- is(String(hcard.photo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "18-object-data-http-uri - photo");
- is(String(hcard.url), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "18-object-data-http-uri - url");
-
- hcard = new hCard(document.getElementById("19-object-data-data-uri"));
-
- is(hcard.fn, "John Doe", "19-object-data-data-uri - fn");
- is(hcard.n["given-name"][0], "John", "19-object-data-data-uri - given-name");
- is(hcard.n["family-name"][0], "Doe", "19-object-data-data-uri - family-name");
- is(String(hcard.logo), "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg==", "19-object-data-data-uri - logo");
- is(String(hcard.photo), "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAASUExURf///8zMzJmZmWZmZjMzMwAAAPOPemkAAAM1SURBVHjaYmBgYGBkYQUBFkYWFiCPCchixQAMCCZAACF0MAMVM4K4TFh0IGsBCCAkOxhYmBnAAKaHhZkZmxaAAGJgYIbpYGBihGgBWsTMzMwE4jIhaWGAYoAAYmCECDExYAcwGxkg5oNIgABigDqLARdgZmGB2wICrKwAAcSA3xKgIxlZ0PwCEEAMBCxhgHoWSQtAADFAAxgfYEJ1GEAAQbQw4tUCsocBYQVAADEgu4uRkREeUCwszEwwLhOKLQABhNDCBA4aSDgwwhIAJKqYUPwCEEAMUK/AUwnc9aywJMCI7DAgAAggBohZ8JTBhGIJzCoWZL8ABBCYidAB8RUjWppkYUG2BSCAGMDqEMZiswUtXgACiAHsFYixTMywGGLGpgUWYgABxAA2mQkWCMyMqFoYmdD8ACQAAogBHJHMrCxg1cyIiICmCkYWDFsAAgiihYmZCewFFpR0BfI3LLch+QUggBiQ0iQjEyMDmh54qCBlUIAAYsCRJsElADQvgWKTlRGeKwECiAF3XgGmMEYQYADZzcoA9z5AAMG9RQCAtEC9DxBADFiyFyMjVi0wABBAWLQwQdIiuhYGWJIACCBg+KKUJ9BoBRdS2LQALQMIIGDQIEmwAO1kYcVWHCDZAhBAqFqYmOAxj2YNtAwDAYAAYmDEiBYWzHKKkRERYiwAAYSphZEZwxZGZiZQVEJTJkAAMTCyokc7M5oORlC5wcoEjxeAAAJqQXU0UB6W5WFmABMtEzMi1wEEEFAbE0YyAUuzMMEsYQalMkQSBQggUDmNPU3C9IA4LCxI+QUggEBiKOU8yExgqccCL3chnkPKlQABhGo6ejHBDKmdUHMlQAAhhQvQaGZGkBIkjcAMywLmI+VKgABCSowsTJhZkhlWXiBpAQggYBqBZl9GVOdBcz0LZqEEEEAMqLULMBLg1THWog9IAwQQA0qiZcRW5aPbAhBADCg1El4tMAAQQAxoiZYZXnTh1AIQQAzo2QlYpDDjcBgrxGEAAcSAJTthswmiBUwDBBC2GpkZJTaRvQ+mAQKIAUuuxdZWQvILQABBmSxMjBj5EpcWgACCMoFOYYSpZyHQHgMIMACt2hmoVEikCQAAAABJRU5ErkJggg==", "19-object-data-data-uri - photo");
-
-
- hcard = new hCard(document.getElementById("20-image-alt"));
-
- is(hcard.fn, "John Doe", "20-image-alt - fn");
- is(hcard.n["given-name"][0], "John", "20-image-alt - given-name");
- is(hcard.n["family-name"][0], "Doe", "20-image-alt - family-name");
- is(String(hcard.logo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "20-image-alt - logo");
- is(String(hcard.photo), "http://mochi.test:8888/tests/browser/microformats/test/picture.png", "20-image-alt - photo");
-
- hcard = new hCard(document.getElementById("21-tel"));
-
- is(hcard.fn, "John Doe", "21-tel - fn");
- is(hcard.n["given-name"][0], "John", "21-tel - given-name");
- is(hcard.n["family-name"][0], "Doe", "21-tel - family-name");
- is(hcard.tel[0].value, "+1.415.555.1231", "21-tel - tel");
- is(hcard.tel[1].value, "+1 415 555 1232", "21-tel - tel");
- is(hcard.tel[1].type[0], "home", "21-tel - type");
- is(hcard.tel[2].value, "+14155551233", "21-tel - tel");
- is(hcard.tel[2].type[0], "msg", "21-tel - type");
- is(hcard.tel[2].type[1], "home", "21-tel - type");
- is(hcard.tel[2].type[2], "work", "21-tel - type");
- is(hcard.tel[2].type[3], "pref", "21-tel - type");
- is(hcard.tel[2].type[4], "voice", "21-tel - type");
- is(hcard.tel[2].type[5], "fax", "21-tel - type");
- is(hcard.tel[2].type[6], "cell", "21-tel - type");
- is(hcard.tel[2].type[7], "video", "21-tel - type");
- is(hcard.tel[2].type[8], "pager", "21-tel - type");
- is(hcard.tel[2].type[9], "bbs", "21-tel - type");
- is(hcard.tel[2].type[10], "car", "21-tel - type");
- is(hcard.tel[2].type[11], "isdn", "21-tel - type");
- is(hcard.tel[2].type[12], "pcs", "21-tel - type");
- isnot(hcard.tel[2].type[13], "invalid", "21-tel - type");
- is(hcard.tel[3].value, "+1 415 555 1234", "21-tel - tel");
- is(hcard.tel[3].type[0], "home", "21-tel - type");
- is(hcard.tel[4].value, "+1.415.555.1235", "21-tel - tel");
- is(hcard.tel[5].value, "+1.415.555.1236", "21-tel - tel");
- is(hcard.tel[6].value, "+1.415.555.1238", "21-tel - tel");
- is(hcard.tel[7].value, "+1.415.555.1239", "21-tel - tel");
- is(hcard.tel[8].value, "+1.415.555.1241", "21-tel - tel");
- is(hcard.tel[9].value, "+1.415.555.1242", "21-tel - tel");
-
- hcard = new hCard(document.getElementById("21-tel.2"));
-
- is(hcard.tel[0].type[0], "home", "21-tel.2 - type");
- is(hcard.tel[0].value, "+1.415.555.1212", "21-tel.2 - tel");
-
- hcard = new hCard(document.getElementById("21-tel.3"));
-
- is(hcard.tel[0].type[0], "home", "21-tel.3 - type (home)");
- is(hcard.tel[0].type[1], "pref", "21-tel.3 - type (pref)");
- is(hcard.tel[0].value, "+1.415.555.1212", "21-tel.3 - tel");
-
- hcard = new hCard(document.getElementById("22-adr"));
-
- is(hcard.fn, "John Doe", "22-adr - fn");
- is(hcard.n["given-name"][0], "John", "22-adr - given-name");
- is(hcard.n["family-name"][0], "Doe", "22-adr - family-name");
- is(hcard.adr[0]["street-address"][0], "1231 Main St.", "22-adr - street-address");
- is(hcard.adr[0].locality, "Beverly Hills", "22-adr - locality");
- is(hcard.adr[0].region, "California", "22-adr - region");
- is(hcard.adr[0]["postal-code"], "90210", "22-adr - postal-code");
- is(hcard.adr[0]["country-name"], "United States of America", "22-adr - country-name");
- is(hcard.adr[1]["post-office-box"], "PO Box 1234", "22-adr - post-office-box");
- is(hcard.adr[1]["street-address"][0], "1232 Main St.", "22-adr - street-address");
- is(hcard.adr[1]["street-address"][1], "Suite 100", "22-adr - street-address");
- is(hcard.adr[1].locality, "Beverly Hills", "22-adr - locality");
- is(hcard.adr[1].region, "California", "22-adr - region");
- is(hcard.adr[1]["postal-code"], "90210", "22-adr - postal-code");
- is(hcard.adr[1]["country-name"], "United States of America", "22-adr - country-name");
- is(hcard.adr[2]["type"][0], "home", "22-adr - type");
- is(hcard.adr[2]["street-address"][0], "1233 Main St.", "22-adr - street-address");
- is(hcard.adr[2].locality, "Beverly Hills", "22-adr - locality");
- is(hcard.adr[2].region, "California", "22-adr - region");
- is(hcard.adr[2]["postal-code"], "90210", "22-adr - postal-code");
- is(hcard.adr[2]["country-name"], "United States of America", "22-adr - country-name");
- is(hcard.adr[3]["type"][0], "dom", "22-adr - type");
- is(hcard.adr[3]["type"][1], "intl", "22-adr - type");
- is(hcard.adr[3]["type"][2], "postal", "22-adr - type");
- is(hcard.adr[3]["type"][3], "parcel", "22-adr - type");
- is(hcard.adr[3]["type"][4], "home", "22-adr - type");
- is(hcard.adr[3]["type"][5], "work", "22-adr - type");
- is(hcard.adr[3]["type"][6], "pref", "22-adr - type");
- is(hcard.adr[3]["street-address"][0], "1234 Main St.", "22-adr - street-address");
- is(hcard.adr[3].locality, "Beverly Hills", "22-adr - locality");
- is(hcard.adr[3].region, "California", "22-adr - region");
- is(hcard.adr[3]["postal-code"], "90210", "22-adr - postal-code");
- is(hcard.adr[3]["country-name"], "United States of America", "22-adr - country-name");
-
- hcard = new hCard(document.getElementById("23-abbr-title-everything"));
-
- is(hcard.fn, "John Doe", "23-abbr-title-everything - fn");
- is(hcard.n["given-name"][0], "Jonathan", "23-abbr-title-everything - given-name");
- is(hcard.n["family-name"][0], "Doe-Smith", "23-abbr-title-everything - family-name");
- is(String(hcard.n["additional-name"]), "John", "23-abbr-title-everything - additional-name");
- is(String(hcard.n["honorific-prefix"]), "Mister", "23-abbr-title-everything - honorific-prefix");
- is(String(hcard.n["honorific-suffix"]), "Medical Doctor", "23-abbr-title-everything - honorific-suffix");
- is(hcard["class"], "public", "23-abbr-title-everything - class");
- is(hcard.geo.latitude, 37.77, "23-abbr-title-everything - geo.latitude");
- is(hcard.geo.longitude, -122.41, "23-abbr-title-everything - geo.longitude");
- is(hcard.bday, "2006-04-04", "23-abbr-title-everything - bday");
- is(hcard.nickname[0], "JJ", "23-abbr-title-everything - nickname");
- is(String(hcard.note[0]), "this is a note", "23-abbr-title-everything - note");
- isnot(String(hcard.note[0]), "this is not a note", "23-abbr-title-everything - note");
- is(hcard.org[0]["organization-name"], "Intellicorp", "23-abbr-title-everything - organization-name");
- is(hcard.org[0]["organization-unit"][0], "Intelligence", "23-abbr-title-everything - organization-unit");
- is(String(hcard.role), "Chief", "23-abbr-title-everything - role");
- is(hcard.tel[0].value, "415.555.1234", "23-abbr-title-everything - tel");
- is(hcard.title[0], "President", "23-abbr-title-everything - title");
- is(hcard.tz, "-0700", "23-abbr-title-everything - tz");
- is(hcard.uid, "abcdefghijklmnopqrstuvwxyz", "23-abbr-title-everything - uid");
- is(hcard.adr[0]["post-office-box"], "Box 1234", "23-abbr-title-everything - post-office-box");
- is(hcard.adr[0]["street-address"][0], "123 Fake Street", "23-abbr-title-everything - street-address");
- is(hcard.adr[0]["extended-address"], "Suite 100", "23-abbr-title-everything - street-address");
- is(hcard.adr[0].locality, "San Francisco", "23-abbr-title-everything - locality");
- is(hcard.adr[0].region, "California", "23-abbr-title-everything - region");
- is(hcard.adr[0]["postal-code"], "12345-6789", "23-abbr-title-everything - postal-code");
- is(hcard.adr[0]["country-name"], "United States of America", "23-abbr-title-everything - country-name");
-
- hcard = new hCard(document.getElementById("25-geo-abbr"));
-
- is(hcard.fn, "Paradise", "25-geo-abbr - fn");
- is(hcard.geo.latitude, 30.267991, "25-geo-abbr - geo.latitude");
- is(hcard.geo.longitude, -97.739568, "25-geo-abbr - geo.longitude");
-
- hcard = new hCard(document.getElementById("26-ancestors"));
-
- is(hcard.fn, "John Doe", "26-ancestors - fn");
- is(hcard.n["given-name"][0], "Jonathan", "26-ancestors - given-name");
- is(hcard.n["family-name"][0], "Doe-Smith", "26-ancestors - family-name");
- is(String(hcard.n["additional-name"]), "John", "26-ancestors - additional-name");
- is(String(hcard.n["honorific-prefix"]), "Mister", "26-ancestors - honorific-prefix");
- is(String(hcard.n["honorific-suffix"]), "Medical Doctor", "26-ancestors - honorific-suffix");
- is(hcard["class"], "public", "26-ancestors - class");
- is(hcard.geo.latitude, 37.77, "26-ancestors - geo.latitude");
- is(hcard.geo.longitude, -122.41, "26-ancestors - geo.longitude");
- is(hcard.bday, "2006-04-04", "26-ancestors - bday");
- is(hcard.nickname[0], "JJ", "26-ancestors - nickname");
- is(String(hcard.note[0]), "this is a note", "26-ancestors - note");
- isnot(String(hcard.note[0]), "this is not a note", "26-ancestors - note");
- is(hcard.org[0]["organization-name"], "Intellicorp", "26-ancestors - organization-name");
- is(hcard.org[0]["organization-unit"][0], "Intelligence", "26-ancestors - organization-unit");
- is(String(hcard.role), "Chief", "26-ancestors - role");
- is(hcard.agent[0].fn, "Bob Smith", "26-ancestors - agent.fn");
- is(String(hcard.agent[0].title), "Executive Assistant", "26-ancestors - agent.title");
- is(hcard.tel[0].value, "415.555.1234", "26-ancestors - tel");
- is(hcard.title[0], "President", "26-ancestors - title");
- is(hcard.tz, "-0700", "26-ancestors - tz");
- is(hcard.uid, "abcdefghijklmnopqrstuvwxyz", "26-ancestors - uid");
- is(hcard.adr[0]["post-office-box"], "Box 1234", "26-ancestors - post-office-box");
- is(hcard.adr[0]["street-address"][0], "123 Fake Street", "26-ancestors - street-address");
- is(hcard.adr[0]["extended-address"], "Suite 100", "26-ancestors - street-address");
- is(hcard.adr[0].locality, "San Francisco", "26-ancestors - locality");
- is(hcard.adr[0].region, "California", "26-ancestors - region");
- is(hcard.adr[0]["postal-code"], "12345-6789", "26-ancestors - postal-code");
- is(hcard.adr[0]["country-name"], "United States of America", "26-ancestors - country-name");
-
- hcard = new hCard(document.getElementById("27-bday-date"));
-
- is(hcard.fn, "john doe", "27-bday-date - fn");
- is(hcard.n["given-name"][0], "john", "27-bday-date - given-name");
- is(hcard.n["family-name"][0], "doe", "27-bday-date - family-name");
- is(hcard.bday, "2000-01-01", "27-bday-date - bday");
-
- hcard = new hCard(document.getElementById("28-bday-datetime"));
-
- is(hcard.fn, "john doe", "28-bday-datetime - fn");
- is(hcard.n["given-name"][0], "john", "28-bday-datetime - given-name");
- is(hcard.n["family-name"][0], "doe", "28-bday-datetime - family-name");
- is(hcard.bday, "2000-01-01T00:00:00", "28-bday-datetime - bday");
-
- hcard = new hCard(document.getElementById("29-bday-datetime-timezone"));
-
- is(hcard.fn, "john doe", "29-bday-datetime-timezone - fn");
- is(hcard.n["given-name"][0], "john", "29-bday-datetime-timezone - given-name");
- is(hcard.n["family-name"][0], "doe", "29-bday-datetime-timezone - family-name");
- is(hcard.bday, "2000-01-01T00:00:00-0800", "29-bday-datetime-timezone - bday");
-
- hcard = new hCard(document.getElementById("30-fn-org.1"));
-
- is(hcard.fn, "W3C", "30-fn-org.1 - fn");
- is(hcard.org[0]["organization-name"], "W3C", "30-fn-org.1 - organization-name");
-
-
- hcard = new hCard(document.getElementById("30-fn-org.2"));
-
- is(hcard.fn, "Dan Connolly", "30-fn-org.2 - fn");
- is(hcard.n["given-name"][0], "Dan", "30-fn-org.2 - given-name");
- is(hcard.n["family-name"][0], "Connolly", "30-fn-org.2 - family-name");
- is(hcard.org[0]["organization-name"], "W3C", "30-fn-org.2 - organization-name");
-
- hcard = new hCard(document.getElementById("30-fn-org.3"));
-
- is(hcard.fn, "W3C", "30-fn-org.3 - fn");
- is(hcard.org[0]["organization-name"], "W3C", "30-fn-org.3 - organization-name");
-
- hcard = new hCard(document.getElementById("30-fn-org.4"));
-
- is(hcard.fn, "World Wide Web Consortium", "30-fn-org.4 - fn");
- is(hcard.org[0]["organization-name"], "World Wide Web Consortium", "30-fn-org.4 - organization-name");
-
- hcard = new hCard(document.getElementById("30-fn-org.5"));
-
- is(hcard.fn, "World Wide Web Consortium", "30-fn-org.5 - fn");
- is(hcard.org[0]["organization-name"], "World Wide Web Consortium", "30-fn-org.5 - organization-name");
-
- hcard = new hCard(document.getElementById("31-include.1"));
-
- is(hcard.fn, "Brian Suda", "31-include.1 - fn");
- is(hcard.n["given-name"][0], "Brian", "31-include.1 - given-name");
- is(hcard.n["family-name"][0], "Suda", "31-include.1 - family-name");
- is(String(hcard.url), "http://suda.co.uk/", "31-include.1 - url");
- is(hcard.email[0].value, "correct@example.com", "31-include.1 - email");
- isnot(hcard.email[0].value, "incorrect@example.com", "31-include.1 - email");
-
- hcard = new hCard(document.getElementById("31-include.2"));
-
- is(hcard.fn, "Brian Suda", "31-include.2 - fn");
- is(hcard.n["given-name"][0], "Brian", "31-include.2 - given-name");
- is(hcard.n["family-name"][0], "Suda", "31-include.2 - family-name");
- is(String(hcard.url), "http://suda.co.uk/", "31-include.2 - url");
- is(hcard.email[0].value, "correct@example.com", "31-include.2 - email");
- isnot(hcard.email[0].value, "incorrect@example.com", "31-include.2 - email");
-
- hcard = new hCard(document.getElementById("31-include.3"));
-
- is(hcard.fn, "Brian Suda", "31-include.3 - fn");
- is(hcard.n["given-name"][0], "Brian", "31-include.3 - given-name");
- is(hcard.n["family-name"][0], "Suda", "31-include.3 - family-name");
- is(String(hcard.url), "http://suda.co.uk/", "31-include.3 - url");
- is(hcard.email[0].value, "correct@example.com", "31-include.3 - email");
- isnot(hcard.email[0].value, "incorrect@example.com", "31-include.3 - email");
-
- hcard = new hCard(document.getElementById("31-include.4"));
-
- is(hcard.fn, "Brian Suda", "31-include.3 - fn");
- is(hcard.n["given-name"][0], "Brian", "31-include.3 - given-name");
- is(hcard.n["family-name"][0], "Suda", "31-include.3 - family-name");
- is(String(hcard.url), "http://suda.co.uk/", "31-include.3 - url");
-
- hcard = new hCard(document.getElementById("32-header.1"));
-
- is(hcard.fn, "Brian Suda", "32-header.1 - fn");
- is(hcard.n["given-name"][0], "Brian", "32-header.1 - given-name");
- is(hcard.n["family-name"][0], "Suda", "32-header.1 - family-name");
- is(hcard.org[0]["organization-name"], "example.org", "32-header.1 - organization-name");
- is(String(hcard.url), "http://example.org/", "32-header.1 - url");
-
- hcard = new hCard(document.getElementById("32-header.2"));
-
- is(hcard.fn, "John Doe", "32-header.2 - fn");
- is(hcard.n["given-name"][0], "John", "32-header.2 - given-name");
- is(hcard.n["family-name"][0], "Doe", "32-header.2 - family-name");
- is(hcard.org[0]["organization-name"], "example.org", "32-header.2 - organization-name");
- is(String(hcard.url), "http://example.org/", "32-header.2 - url");
-
- hcard = new hCard(document.getElementById("33-area.1"));
-
- is(hcard.fn, "Joe Public", "33-area.1 - fn");
- is(hcard.n["given-name"][0], "Joe", "33-area.1 - given-name");
- is(hcard.n["family-name"][0], "Public", "33-area.1 - family-name");
- is(String(hcard.url), "http://example.com/", "33-area.1 - url");
- is(hcard.email[0].value, "joe@example.com", "33-area.1 - email");
-
- hcard = new hCard(document.getElementById("33-area.2"));
-
- is(hcard.fn, "Joe Public", "33-area.2 - fn");
- is(String(hcard.url), "http://example.com/", "33-area.2 - url");
- is(hcard.email[0].value, "joe@example.com", "33-area.2 - email");
- is(hcard.org[0]["organization-name"], "Joe Public", "33-area.2 - organization-name");
-
- hcard = new hCard(document.getElementById("33-area.3"));
-
- is(hcard.fn, "Joe Public", "33-area.3 - fn");
- is(String(hcard.url), "http://example.com/", "33-area.3 - url");
- is(hcard.email[0].value, "joe@example.com", "33-area.3 - email");
- is(hcard.org[0]["organization-name"], "Joe Public", "33-area.3 - organization-name");
-
- hcard = new hCard(document.getElementById("33-area.4"));
-
- is(hcard.fn, "Joe Public", "33-area.4 - fn");
- is(String(hcard.url), "http://example.com/", "33-area.4 - url");
- is(hcard.email[0].value, "joe@example.com", "33-area.4 - email");
- is(hcard.org[0]["organization-name"], "Joe Public", "33-area.4 - organization-name");
-
- hcard = new hCard(document.getElementById("33-area.5"));
-
- is(hcard.fn, "Joe Public", "33-area.5 - fn");
- is(String(hcard.url), "http://example.com/", "33-area.5 - url");
- is(hcard.email[0].value, "joe@example.com", "33-area.5 - email");
- is(hcard.org[0]["organization-name"], "Joe Public", "33-area.5 - organization-name");
-
- hcard = new hCard(document.getElementById("34-notes"));
-
- is(hcard.fn, "Joe Public", "34-notes - fn");
- is(hcard.n["given-name"][0], "Joe", "34-notes - given-name");
- is(hcard.n["family-name"][0], "Public", "34-notes - family-name");
- is(String(hcard.note[0]), "Note 1", "34-notes - note");
- isnot(String(hcard.note[1]), "Note 2", "34-notes - note");
- is(String(hcard.note[1]), "Note 3", "34-notes - note");
- is(String(hcard.note[2]), "Note 4 with a ; and a , to be escaped", "34-notes - note");
-
- hcard = new hCard(document.getElementById("35-include-pattern.1"));
-
- is(hcard.fn, "James Levine", "35-include-pattern.1 - fn");
- is(hcard.n["given-name"][0], "James", "35-include-pattern.1 - given-name");
- is(hcard.n["family-name"][0], "Levine", "35-include-pattern.1 - family-name");
-
- hcard = new hCard(document.getElementById("35-include-pattern.2"));
-
- is(hcard.fn, "James Levine", "35-include-pattern.2 - fn");
- is(hcard.n["given-name"][0], "James", "35-include-pattern.2 - given-name");
- is(hcard.n["family-name"][0], "Levine", "35-include-pattern.2 - family-name");
- is(hcard.org[0]["organization-name"], "SimplyHired", "35-include-pattern.2 - organization-name");
- is(hcard.title[0], "Microformat Brainstormer", "35-include-pattern.2 - title");
-
- hcard = new hCard(document.getElementById("35-include-pattern.3"));
-
- is(hcard.fn, "James Levine", "35-include-pattern.3 - fn");
- is(hcard.n["given-name"][0], "James", "35-include-pattern.3 - given-name");
- is(hcard.n["family-name"][0], "Levine", "35-include-pattern.3 - family-name");
- is(hcard.org[0]["organization-name"], "SimplyHired", "35-include-pattern.3 - organization-name");
- is(hcard.title[0], "Microformat Brainstormer", "35-include-pattern.3 - title");
-
- hcard = new hCard(document.getElementById("36-categories.1"));
-
- is(hcard.fn, "john doe", "36-categories.1 - fn");
- is(hcard.n["given-name"][0], "john", "36-categories.1 - given-name");
- is(hcard.n["family-name"][0], "doe", "36-categories.1 - family-name");
- is(hcard.category[0], "C1", "36-categories.1 - category");
- isnot(hcard.category[0], "C1a", "36-categories.1 - category");
- is(hcard.category[1], "C2a", "36-categories.1 - category");
- isnot(hcard.category[1], "C2", "36-categories.1 - category");
- is(hcard.category[2], "C3", "36-categories.1 - category");
- isnot(hcard.category[2], "C3a", "36-categories.1 - category");
- isnot(hcard.category[2], "C3b", "36-categories.1 - category");
- is(hcard.category[3], "C4", "36-categories.1 - category");
- is(hcard.category[4], "C5", "36-categories.1 - category");
- isnot(hcard.category[4], "C5a", "36-categories.1 - category");
- isnot(hcard.category[4], "C5b", "36-categories.1 - category");
- is(hcard.category[5], "C6", "36-categories.1 - category");
- isnot(hcard.category[4], "C6a", "36-categories.1 - category");
- isnot(hcard.category[4], "C6b", "36-categories.1 - category");
- is(hcard.category[6], "C7", "36-categories.1 - category");
- isnot(hcard.category[4], "C7a", "36-categories.1 - category");
- isnot(hcard.category[4], "C7b", "36-categories.1 - category");
- is(hcard.category[7], "C8", "36-categories.1 - category");
- isnot(hcard.category[4], "C8a", "36-categories.1 - category");
- isnot(hcard.category[4], "C8b", "36-categories.1 - category");
- is(hcard.category[8], "C9", "36-categories.1 - category");
- isnot(hcard.category[4], "C9a", "36-categories.1 - category");
- isnot(hcard.category[4], "C9b", "36-categories.1 - category");
-
- hcard = new hCard(document.getElementById("37-singleton"));
-
- is(hcard.fn, "john doe 1", "37-singleton - fn");
- is(hcard.n["given-name"][0], "john", "37-singleton - given-name");
- is(hcard.n["family-name"][0], "doe", "37-singleton - family-name");
- is(hcard.uid, "unique-id-1", "37-singleton - uid");
- is(hcard.tz, "+0600", "37-singleton - tz");
- is(hcard["sort-string"], "d", "37-singleton - sort-string");
- is(hcard.geo.latitude, 123.45, "37-singleton - geo.latitude");
- is(hcard.geo.longitude, 67.89, "37-singleton - geo.longitude");
- is(hcard["class"], "public", "37-singleton - class");
- is(hcard.bday, "2006-07-07", "37-singleton - bday");
- is(hcard.rev, "2006-07-07", "37-singleton - rev");
-
- hcard = new hCard(document.getElementById("38-uid.1"));
-
- is(hcard.fn, "Ryan King", "38-uid.1 - fn");
- is(hcard.n["given-name"][0], "Ryan", "38-uid.1 - given-name");
- is(hcard.n["family-name"][0], "King", "38-uid.1 - family-name");
- is(hcard.uid, "http://theryanking.com/contact/", "38-uid.1 - uid");
- is(hcard.url[0], "http://theryanking.com/contact/", "38-uid.1 - url");
-
- hcard = new hCard(document.getElementById("38-uid.2"));
-
- is(hcard.fn, "Ryan King", "38-uid.2 - fn");
- is(hcard.n["given-name"][0], "Ryan", "38-uid.2 - given-name");
- is(hcard.n["family-name"][0], "King", "38-uid.2 - family-name");
- is(hcard.uid, "http://mochi.test:8888/tests/browser/microformats/test/contact/", "38-uid.2 - uid");
- is(hcard.url[0], "http://mochi.test:8888/tests/browser/microformats/test/contact/", "38-uid.2 - url");
-
- hcard = new hCard(document.getElementById("38-uid.3"));
-
- is(hcard.fn, "Ryan King", "38-uid.3 - fn");
- is(hcard.n["given-name"][0], "Ryan", "38-uid.3 - given-name");
- is(hcard.n["family-name"][0], "King", "38-uid.3 - family-name");
- is(hcard.uid, "http://mochi.test:8888/tests/browser/microformats/test/contact/", "38-uid.3 - uid");
- is(hcard.url[0], "http://mochi.test:8888/tests/browser/microformats/test/contact/", "38-uid.3 - url");
-
- hcard = new hCard(document.getElementById("38-uid.4"));
-
- is(hcard.fn, "Ryan King", "38-uid.4 - fn");
- is(hcard.n["given-name"][0], "Ryan", "38-uid.4 - given-name");
- is(hcard.n["family-name"][0], "King", "38-uid.4 - family-name");
- is(hcard.uid, "http://theryanking.com/contact/", "38-uid.4 - uid");
- is(hcard.url[0], "http://theryanking.com/contact/", "38-uid.4 - url");
-
- hcard = new hCard(document.getElementById("39-noteHTML"));
-
- is(String(hcard.note[0]), "Note", "39-noteHTML - note");
- is(hcard.note[0].toHTML(), "<b>Note</b>", "39-noteHTML - note as HTML");
- is(String(hcard.note[0].match("Note")), "Note", "39-noteHTML - match in note");
-
- hcard = new hCard(document.getElementById("email-type"));
- is(String(hcard.email[0].type), "internet", "email - type no value (type)");
- is(hcard.email[0].value, "john@example.com", "email - type no value (value)");
-}
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_Microformats_negative.html
+++ /dev/null
@@ -1,112 +0,0 @@
-<html>
-<head>
- <title>Testing Mixed Up Microformat APIs</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body id="contentbody">
- <div id="testhere">
- <!-- Frames -->
- <frameset>
- <frame id="frame1">
- <div>
- <span class="notAMicroformat" id="notme">
- <abbr> class="foo">I am not a microformat</abbr>
- <abbr> class="title">Foolish title, not a format</abbr>
- </span>
- </div>
- </frame>
- <frame id="frame2">
- <div class="vcalendar">
- <span class="vevent" id="15-calendar-xml-lang">
- <a class="url" href="http://www.web2con.com/">
- <span class="summary">Web 2.0 Conference</span>:
- <abbr class="dtend" title="2005-10-08">7</abbr>,
- at the <span class="location">Argent Hotel, San Francisco, CA</span>
- </a>
- </span>
- </div>
- </frame>
- </frameset>
- </div>
-
- <div id="content">
- <!-- some really messed up markup-->
- <p class="vcard" id="23-abbr-title-everything">
- <div id="random div no ending div either">
- <abbr class="fn" title="John Doe">foo</abbr>
- <span class="n"/>
- <abbr class="foo" title="JJ">jj</abbr>
- <abbr class="free" title="2006-04-04">April 4, 2006</abbr>
- <span class="adr">
- <abbr class="invalid" title="Box 1234">B. 1234</abbr>
- <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
- <abbr class="street-address" title="123 Fake Street"/>
- <abbr class="locality" title="San Francisco">San Fran</abbr>
- <abbr class="region" title="California">CA</abbr>
- <abbr class="postal-code" title="12345-6789">12345</abbr>
- <abbr class="country-name" title="United States of America">USA</abbr>
- <abbr class="typo" titl="work">workplace</abbr>
- </span>
- <span class="org">
- <abbr class="organization-name" title="Intellicorp">foo</abbr>
- <abbr class="organization-unit" title="Intelligence">bar</abbr>
- <!-- <abbr class="category" title=""></abbr> -->
- <abbr class="note" title="this is a note">this is not a note</abbr>
- <!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
- <!-- <abbr class="sort-string" title=""></abbr> -->
- <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
- <abbr class="class" title="public">pub</abbr>
- <!-- <abbr class="key" title=""></abbr> -->
- </span>
-
- <!-- Ok, the test, here we go -->
- <pre id="test">
- <script class="testbody" type="text/javascript">
-
- test_MicroformatsAPI();
-
- function test_MicroformatsAPI() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- // Test to see if we can get the invalid vcard
- var mfs = Microformats.get("hCard",
- document.getElementById("content"),
- { });
-
- is(mfs.length, 0, "Check that we can't get invalid vcard");
-
- // Invalid hCalendar - doesn't have a dtstart
- mfs = Microformats.get("hCalendar",
- document.getElementById("testhere"),
- {recurseExternalFrames: true});
- is(mfs.length, 0, "Check that we don't pick up invalid MFs.");
-
- mfs = Microformats.get("notAMicroformat",
- document.getElementById("testhere"),
- {recurseExternalFrames: true});
-
- is(mfs, undefined, "No microformat called notAMicroformat");
-
- // What if we try another way?
- is(Microformats.isMicroformat(document.getElementById("notme")), false,
- "Check that the NotAMicroformat is still not a microformat");
-
- // Attempt to physically add one to the object
- try {
- Microformats.push("notAMicroformat");
- } catch (ex) {
- ok(true, "Check thrown exception when adding to microformats object");
- }
-
- // Attempt to delete one from the object
- try {
- Microformats.pop();
- } catch (ex) {
- ok(true, "Check that exception thrown when removing items from Microformats");
- }
- }
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/microformats/tests/test_framerecursion.html
+++ /dev/null
@@ -1,63 +0,0 @@
-<!-- Demonstrates that we are always counting MF's in a <frame> tag, and NEVER
- counting MF's in an <iframe> regardless of what the "frame recursion" bit
- is set to. -->
-<html>
-<head>
- <title>Testing Mixed Up Microformat APIs</title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
-</head>
-<body id="contentbody">
- <pre id="test">
- <script class="testbody" type="text/javascript">
-
- // Start the test once the iFrame loads
- function onLoad() {
- test_MicroformatsAPI();
- }
-
- function test_MicroformatsAPI() {
- var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
-
- count = Microformats.count("geo",
- document.getElementById("contentbody"),
- {recurseExternalFrames: false},
- 0);
- is(count, 1, "Only one geo - we don't count external frames");
-
- count = Microformats.count("geo",
- document.getElementById("contentbody"),
- {recurseExternalFrames: true});
- is(count, 2, "Two Geo's - one in frame and one in iframe");
- }
- </script>
- </pre>
-
- <frameset>
- <frame id="frame1">
- <div>
- <span class="notAMicroformat" id="notme">
- <abbr class="foo">I am not a microformat</abbr>
- <abbr class="title">Foolish title, not a format</abbr>
- </span>
- </div>
- </frame>
- <frame id="frame3">
- <span class="geo" id="02-geo-abbr-latlong" >
- <abbr class="latitude" title="75.77">Far Northern</abbr>
- <abbr class="longitude" title="-122.41">Canada</abbr>
- </span>
- </frame>
- <frame id="frame2">
- <div class="stuff">
- <span>Testing is Fun!</span>
- </div>
- </frame>
- </frameset>
-
- <!-- Geo -->
- <iframe id="iframe" src="geo.html" onload="onLoad();">
- </iframe>
-</body>
-</html>