Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/test/tools/helper.js

Issue 125733002: Add vulcanize to tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/test/tools/helper.js
diff --git a/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/test/tools/helper.js b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/test/tools/helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b08e98a5555c19123f5e3dac90cdb446ed2939f
--- /dev/null
+++ b/tools/vulcanize/node_modules/vulcanize/node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/test/tools/helper.js
@@ -0,0 +1,51 @@
+var fs = require("fs"),
+ path = require("path"),
+ htmlparser2 = require("htmlparser2"),
+ DomUtils = htmlparser2.DomUtils,
+ CSSselect = require("../../");
+
+function getDOMFromPath(path, options){
+ return htmlparser2.parseDOM(fs.readFileSync(path).toString(), options);
+}
+
+module.exports = {
+ CSSselect: CSSselect,
+ getFile: function(name, options){
+ return getDOMFromPath(path.join(__dirname, "docs", name), options);
+ },
+ getDOMFromPath: getDOMFromPath,
+ getDOM: htmlparser2.parseDOM,
+ getDefaultDom: function(){
+ return htmlparser2.parseDOM(
+ "<elem id=foo><elem class='bar baz'><tag class='boom'> This is some simple text </tag></elem></elem>"
+ );
+ },
+ getDocument: function(path){
+ var document = getDOMFromPath(path);
+
+ document.getElementsByTagName = function(name){
+ return DomUtils.getElementsByTagName("*", document);
+ };
+ document.getElementById = function(id){
+ return DomUtils.getElementById(id, document);
+ };
+ document.createTextNode = function(content){
+ return {
+ type: "text",
+ data: "content"
+ };
+ };
+ document.createElement = function(name){
+ return {
+ type: "tag",
+ name: name,
+ children: [],
+ attribs: {}
+ };
+ };
+ document.body = DomUtils.getElementsByTagName("body", document, true, 1)[0];
+ document.documentElement = document.filter(DomUtils.isTag)[0];
+
+ return document;
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698