>From 3881be938b602018cf426006d9a29e32b49d1041 Mon Sep 17 00:00:00 2001 From: Kevin Carhart Date: Wed, 29 Jun 2016 20:10:30 -0700 Subject: [PATCH] Changes that get you successfully from a click on a diedrescher.com link, to javascript, to xhr, to content coming back over xhr and into a div on the edbrowse side, thus illustrating the complete circuit for other pages as well. Please see edbrowse-dev post for more detail of what was done and why. --- src/decorate.c | 25 ++++++++- src/jseng-moz.cpp | 16 +++--- src/startwindow.js | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 177 insertions(+), 14 deletions(-) diff --git a/src/decorate.c b/src/decorate.c index 3773e26..4092ac5 100644 --- a/src/decorate.c +++ b/src/decorate.c @@ -820,6 +820,7 @@ call out to process those and add them to the object */ /* Other attributes that are expected by pages, even if they * aren't populated at domLink-time */ set_property_string(io, "className", ""); +set_property_string(io, "class", ""); set_property_string(io, "nodeValue",""); instantiate_array(io, "attributes"); set_property_object(io, "ownerDocument", cw->docobj); @@ -894,6 +895,7 @@ set_property_object(io, "ownerDocument", cw->docobj); if (htmlclass) { set_property_string(io, "className", htmlclass); + set_property_string(io, "class", htmlclass); } t->jv = io; @@ -1025,6 +1027,7 @@ static void jsNode(struct htmlTag *t, bool opentag) w = emptyString; set_property_string(t->jv, "data", w); set_property_string(t->jv, "nodeName", "text"); + set_property_number(t->jv, "nodeType", 3); } break; @@ -1050,52 +1053,62 @@ static void jsNode(struct htmlTag *t, bool opentag) }else { set_property_string(t->jv, "data", ""); } + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_FORM: domLink(t, "Form", "action", "forms", cw->docobj, 0); set_onhandlers(t); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_INPUT: formControlJS(t); if (t->itype == INP_TA) establish_inner(t->jv, t->value, 0, true); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_OPTION: optionJS(t); // The parent child relationship has already been established, // don't break, just return; + set_property_number(t->jv, "nodeType", 1); return; case TAGACT_A: domLink(t, "Anchor", "href", "anchors", cw->docobj, 0); set_onhandlers(t); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_HEAD: domLink(t, "Head", 0, "heads", cw->docobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_BODY: domLink(t, "Body", 0, "bodies", cw->docobj, 0); set_onhandlers(t); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_OL: case TAGACT_UL: case TAGACT_DL: domLink(t, "Lister", 0, 0, cw->docobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_LI: domLink(t, "Listitem", 0, 0, cw->docobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_TABLE: domLink(t, "Table", 0, "tables", cw->docobj, 0); /* create the array of rows under the table */ instantiate_array(t->jv, "rows"); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_TR: @@ -1103,6 +1116,7 @@ static void jsNode(struct htmlTag *t, bool opentag) domLink(t, "Trow", 0, "rows", above->jv, 0); instantiate_array(t->jv, "cells"); } + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_TD: @@ -1110,16 +1124,19 @@ static void jsNode(struct htmlTag *t, bool opentag) domLink(t, "Cell", 0, "cells", above->jv, 0); establish_inner(t->jv, t->innerHTML, 0, false); } + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_DIV: domLink(t, "Div", 0, "divs", cw->docobj, 0); establish_inner(t->jv, t->innerHTML, 0, false); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_OBJECT: domLink(t, "HtmlObj", 0, "htmlobjs", cw->docobj, 0); establish_inner(t->jv, t->innerHTML, 0, false); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_SPAN: @@ -1128,28 +1145,34 @@ static void jsNode(struct htmlTag *t, bool opentag) case TAGACT_OVB: domLink(t, "Span", 0, "spans", cw->docobj, 0); establish_inner(t->jv, t->innerHTML, 0, false); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_AREA: domLink(t, "Area", "href", "areas", cw->docobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_FRAME: domLink(t, "Frame", "src", "frames", cw->winobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_IMAGE: domLink(t, "Image", "src", "images", cw->docobj, 0); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_P: domLink(t, "P", 0, "paragraphs", cw->docobj, 0); establish_inner(t->jv, t->innerHTML, 0, false); + set_property_number(t->jv, "nodeType", 1); break; case TAGACT_TITLE: if (cw->ft) set_property_string(cw->docobj, "title", cw->ft); + set_property_number(t->jv, "nodeType", 1); break; } /* switch */ @@ -1251,7 +1274,7 @@ const struct tagInfo availableTags[] = { {"form", "a form", TAGACT_FORM, 10, 1}, {"button", "a button", TAGACT_INPUT, 0, 4}, {"frame", "a frame", TAGACT_FRAME, 2, 4}, - {"iframe", "a frame", TAGACT_FRAME, 2, 4}, +// {"iframe", "a frame", TAGACT_FRAME, 2, 4}, {"map", "an image map", TAGACT_MAP, 2, 4}, {"area", "an image map area", TAGACT_AREA, 0, 4}, {"table", "a table", TAGACT_TABLE, 10, 1}, diff --git a/src/jseng-moz.cpp b/src/jseng-moz.cpp index 429353e..9a0adca 100644 --- a/src/jseng-moz.cpp +++ b/src/jseng-moz.cpp @@ -1888,12 +1888,17 @@ static JSObject *setTimeout(unsigned int argc, jsval * argv, bool isInterval) const char *allocatedName = NULL; const char *s = NULL; - if (argc != 2 || !JSVAL_IS_INT(argv[1])) - goto badarg; v0 = argv[0]; - v1 = argv[1]; - n = JSVAL_TO_INT(v1); + if (argc != 2 || !JSVAL_IS_INT(argv[1])) + { + // if only one parameter was supplied, hardcode + // a number of milliseconds. 1? 100? 1000? + n = 100; + } else { + v1 = argv[1]; + n = JSVAL_TO_INT(v1); + } if (JSVAL_IS_STRING(v0) || v0.isObject() && JS_ValueToObject(jcx, v0, fo.address()) && @@ -1980,9 +1985,6 @@ abort: return to; } -badarg: - JS_ReportError(jcx, "invalid arguments to %s()", methname); - return NULL; } /* setTimeout */ /* set timer and set interval */ diff --git a/src/startwindow.js b/src/startwindow.js index b9b8451..77053c5 100644 --- a/src/startwindow.js +++ b/src/startwindow.js @@ -16,7 +16,8 @@ The classes are created first, so that you can write meaningful prototypes here. * Better to have something than nothing at all. */ height = 768; width = 1024; -status = 0; +// document.status is removed because it creates a conflict with +// the status property of the XMLHttpRequest implementation defaultStatus = 0; returnValue = true; menubar = true; @@ -30,6 +31,8 @@ document.bgcolor = "white"; document.readyState = "loading"; document.nodeType = 9; document.implementation = {}; +// pages seem to want document.style to exist +document.style = {"bgcolor":"white"}; screen = new Object; screen.height = 768; @@ -64,7 +67,7 @@ return document.gebtn$(this, s); } document.gebtn$ = function(top, s) { var a = new Array; -if(s === '*' || (top.nodeName && top.nodeName === s)) +if(s === '*' || (top.nodeName && top.nodeName.toLowerCase() === s)) a.push(top); if(top.childNodes) { for(var i=0; i 0){ this.readyState = 4; +this.status = 200; +this.statusText = "OK"; this.onreadystatechange(); } @@ -1247,3 +1333,55 @@ new_url = sideprotocol + '//' + sidehost + path; return new_url; } +document.defaultView = function() +{ +return this.style; +} + +document.defaultView.getComputedStyle = function() +{ + obj = new CSSStyleDeclaration; + obj.element = document; + obj.style = document.style; + return obj; +} + +getComputedStyle = function(n) +{ + obj = new CSSStyleDeclaration; + obj.element = this; + obj.style = new Array; + obj.style.push({n:obj.style[n]}); + return obj; +} + +CSSStyleDeclaration = function(){ + this.element = null; + this.style = null; +}; + +CSSStyleDeclaration.prototype = { +getPropertyValue: function (n) + { + if (this.style[n] == undefined) + { + this.style[n] = 0; + return 0; + } else { + return this.style[n]; + } + } +} + +Event = function(options){ + this._bubbles = true; + this._cancelable = true; + this._cancelled = false; + this._currentTarget = null; + this._target = null; + this._eventPhase = Event.AT_TARGET; + this._timeStamp = new Date().getTime(); + this._preventDefault = false; + this._stopPropagation = false; +}; + -- 1.8.3.2