ref: dd52020bb30338f9eb23910e2fe09a6667dcafcd
parent: 6f72ddfb9a89d2d264fb8b4d59431dbe0342d4f6
author: Philip Silva <[email protected]>
date: Sun Jan 24 06:39:04 EST 2021
referrer
--- a/domino-lib/Document.js
+++ b/domino-lib/Document.js
@@ -367,7 +367,7 @@
contentType: { get: function contentType() { return this._contentType; } },
URL: { get: function URL() { return this._address; } },
domain: { get: utils.nyi.bind(this, 'domain'), set: utils.nyi.bind(this, 'domain') },
- referrer: { get: utils.nyi.bind(this, 'referrer') },
+ referrer: { get: opossum.referrer },
//cookie: { get: utils.nyi.bind(this, 'cookie get'), set: utils.nyi.bind(this, 'cookie set') },
lastModified: { get: utils.nyi.bind(this, 'lastModified get') },
location: {
--- a/domino/domino.go
+++ b/domino/domino.go
@@ -112,7 +112,7 @@
var domino = require('domino-lib/index');
var Element = domino.impl.Element; // etc
- Object.assign(this, domino.createWindow(s.html, 'http://example.com'));
+ Object.assign(this, domino.createWindow(opossum.html, 'http://example.com'));
window = this;
window.parent = window;
window.top = window;
@@ -168,12 +168,14 @@
type S struct {
Buf string `json:"buf"`
HTML string `json:"html"`
+ Referrer func() string `json:"referrer"`
}
vm.SetFieldNameMapper(goja.TagFieldNameMapper("json", true))
- vm.Set("s", S{
+ vm.Set("opossum", S{
HTML: d.html,
Buf: "yolo",
+ Referrer: func() string { return "https://example.com" },
})
}
--- a/domino/domino_test.go
+++ b/domino/domino_test.go
@@ -456,3 +456,20 @@
}
d.Stop()
}
+
+func TestReferrer(t *testing.T) {
+ d := NewDomino(simpleHTML)
+ d.Start()
+ script := `
+ document.referrer;
+ `
+ res, err := d.Exec(script, true)
+ if err != nil {
+ t.Fatalf("%v", err)
+ }
+ t.Logf("res=%v", res)
+ if res != "https://example.com" {
+ t.Fatal()
+ }
+ d.Stop()
+}