Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rw-asking: a weaklist that doesn't work and an object with elements that can't be copied or queried

3 views
Skip to first unread message

R.Wieser

unread,
Feb 21, 2021, 2:54:22 AM2/21/21
to
Hello all,

Over two weeks ago I posted a question with the subject "JS log-dumping an
object and circular references problem". Although I've been able to create
something that seems to work, two questions remain :

A "weaklist" that could solve the "circular references" problem does not
want to have objects added to it.
Reference : seen.add(value))

Trying to copy one of the objects elements into a variable fails. Directly
trying to inspect the element fails to
Reference : var value = arr[item]
Also : typeof(arr[item])

I would appriciate it if someone could explain the failure of either of the
above to me.

Regards,
Rudy Wieser


Big Al

unread,
Feb 21, 2021, 7:08:56 AM2/21/21
to
Wrong Newsgroup?!
This is Mozilla General and usually that implies Firefox or Thunderbird.

--
Linux Mint Cinnamon 20.1 64bit, Dell Inspiron 5570 laptop
Quad Core i7-8550U, 16G Memory, 512G SSD, 750G & 1TB HDDs
____ _ _ _
| __ )(_) __ _ / \ | |
| _ \| |/ _` | / _ \ | |
| |_) | | (_| | / ___ \| |
|____/|_|\__, | /_/ \_\_|
|___/

WaltS48

unread,
Feb 21, 2021, 8:14:59 AM2/21/21
to
On 2/21/21 7:08 AM, Big Al wrote:
On 2/21/21 2:54 AM, this is what R.Wieser wrote:
Hello all,

Over two weeks ago I posted a question with the subject "JS log-dumping an
object and circular references problem".   Although I've been able to create
something that seems to work, two questions remain :

A "weaklist" that could solve the "circular references" problem does not
want to have objects added to it.
Reference : seen.add(value))

Trying to copy one of the objects elements into a variable fails.  Directly
trying to inspect the element fails to
Reference : var value = arr[item]
Also : typeof(arr[item])

I would appriciate it if someone could explain the failure of either of the
above to me.

Regards,
Rudy Wieser


Wrong Newsgroup?!
This is Mozilla General and usually that implies Firefox or Thunderbird.

Look again.

Newsgroups: mozilla.general
Subject: JS log-dumping an object and circular references problem
Date: Mon, 8 Feb 2021 09:43:30 +0100
-- 
OS: Fedora 33 Workstation - Gnome Desktop
https://www.thunderbird.net/en-US/get-involved/

R.Wieser

unread,
Feb 21, 2021, 1:00:14 PM2/21/21
to
Al,

> Wrong Newsgroup?!
> This is Mozilla General and usually that implies Firefox or Thunderbird.

Than I think I'm posting in the right newsgroup.

I encountered those two problems while writing a XUL addon for FF v52 (the
last one that will work under XP if you're wondering).

... Which I mentioned in first line of the message I started the
referred-to thread with. <whistle>.

Regards,
Rudy Wieser


Big Al

unread,
Feb 21, 2021, 6:50:10 PM2/21/21
to
Sorry, as much as I'm a programmer I never saw any mention of writing code for FF.
And what you were posting was, sorry to say, way over my head far enough I had no idea what you were writing.

R.Wieser

unread,
Feb 22, 2021, 2:22:15 AM2/22/21
to
Al,

> Sorry, as much as I'm a programmer I never saw any mention of writing code
> for FF.

I thought that the choice of newsgroup would have been a bit of a dead
give-away ? Besides it being specified in the referred-to thread ofcourse.

> And what you were posting was, sorry to say, way over my head far enough I
> had no idea what you were writing.

:-) a XUL addon is just a bit of JS that ties some (complexly-named) FF API
functions together.

All that I did was to ask FF to call my function whenever a new web resource
was received ("http-on-examine-response"), so that I could extract, from the
object it supplied as the first argument to my callback function, the
webpages HTTP status value.

Have you done any JS at all ? In that case the "object-dump-javascript"
code in the link I provided in the initial message (which could be used
anywhere, including on a webpage) should not be too hard to follow.

And by the way : JS is just a "tool" language for me, which I seldom use
(just GreaseMonkey and XUL scripts) and as such consider myself barely a
novice in it. Luckily my google-fu most never lets me down when I need to
figure something out. :-)

Regards,
Rudy Wieser


Big Al

unread,
Feb 22, 2021, 9:01:36 AM2/22/21
to
On 2/22/21 2:20 AM, this is what R.Wieser wrote:
> Al,
>
>> Sorry, as much as I'm a programmer I never saw any mention of writing code
>> for FF.
>
> I thought that the choice of newsgroup would have been a bit of a dead
> give-away ? Besides it being specified in the referred-to thread ofcourse.
>
I don't see any links anywhere. Unless some thread didn't get to my thunderbird.
With this post, there are only 7 posts total and none have any links.

>> And what you were posting was, sorry to say, way over my head far enough I
>> had no idea what you were writing.
>
> :-) a XUL addon is just a bit of JS that ties some (complexly-named) FF API
> functions together.
>
> All that I did was to ask FF to call my function whenever a new web resource
> was received ("http-on-examine-response"), so that I could extract, from the
> object it supplied as the first argument to my callback function, the
> webpages HTTP status value.
>
> Have you done any JS at all ? In that case the "object-dump-javascript"
> code in the link I provided in the initial message (which could be used
> anywhere, including on a webpage) should not be too hard to follow.
>
> And by the way : JS is just a "tool" language for me, which I seldom use
> (just GreaseMonkey and XUL scripts) and as such consider myself barely a
> novice in it. Luckily my google-fu most never lets me down when I need to
> figure something out. :-)
>
> Regards,
> Rudy Wieser
>
>

Dave Royal

unread,
Feb 22, 2021, 9:33:59 AM2/22/21
to
Is 'seen' actually a WeakSet?
Does the 'weak' make any difference?
How is 'seen' declared, and where (scope)?
Is the extra ) in the .add statement a typo in the post?
Perhaps 'arr' is empty?

Without seeing the code this is just guesswork.
I suggest you share the code.
--
(Remove numerics from email address)

R.Wieser

unread,
Feb 22, 2021, 1:13:00 PM2/22/21
to
Al,

> I don't see any links anywhere. Unless some thread didn't get to my
> thunderbird.
> With this post, there are only 7 posts total and none have any links.

I take it you didn't notice that you don't have the post that started that
thread. That one contains, as one is supposed to provide, all the info and
the link I spoke of.

But if you still want o take a peek here its again:

https://stackoverflow.com/questions/749266/object-dump-javascript
Function "mydump" by zhongshu (Jun 10 '10 at 4:04)

Regards,
Rudy Wieser


R.Wieser

unread,
Feb 22, 2021, 1:48:00 PM2/22/21
to
Dave,

> Is 'seen' actually a WeakSet?

Yes. I created it myself.

> Does the 'weak' make any difference?

Are you suggesting that *in this case* I should just use something else ? I
already did that (see below). :-)

But that doesn't mean I do not need an answer to my "why doesn't the
WeakList work when it should" question. Either so I know I made a mistake
and it actually does work (and how), or so I do not waste any time and
energy in trying to make it work the next time I have use for it.

> How is 'seen' declared, and where (scope)?

Just before the function, and provided as an argument.

Also,
1) the error message was explicit about the WeakList being the culprit.
2) when I use a normal array instead it works.

> Is the extra ) in the .add statement a typo in the post?

Yeah. :-\ Copy-pasted it from the initial message in the other thread.

> Perhaps 'arr' is empty?

In that case I would not have gotten an "item", as that is retieved by way
of a "for(var item in arr)" loop :-)
(see the linked-to "mydump" routine).

Regards,
Rudy Wieser


WaltS48

unread,
Feb 22, 2021, 2:26:41 PM2/22/21
to

Maybe ask there, or a JavaScript newsgroup on a Usenet server account.

I recall being subscribed to one eons ago.

Probably was alt.comp.lang.javascript, or you might check out one of the comp.infosystems.www.authoring groups.

R.Wieser

unread,
Feb 23, 2021, 4:52:53 AM2/23/21
to
Walt,

> Maybe ask there, or a JavaScript newsgroup on a Usenet server account.

I would, If I would be thinking its a Javascript problem. Which I don't. I
think its FF related. And those problems belong here.

Regards,
Rudy Wieser


R.Wieser

unread,
Feb 23, 2021, 4:52:53 AM2/23/21
to
Dave,

I forgot to mention that I also tried to go the JSON.stringify() road using
a "replacer" function (pretty-much copy-pasting it). It it also used a
WeakList, and again barfed throwing the same error. IOW, its not something
related to my coding if you might think that. :-)

With the absense of someone recognising the problem I just did a few more
tests.

I ran, inside the addon, the "examples" code I found here :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
, which worked. Jay!

However, when I try to add, in that same code, the object as provided as the
"http-on-examine-response" callbacks first argument I get a "TypeError:
cannot use the given object as a weak map key".

It simply looks like that the object delivered by FF isn't quite compatible
with JS. Which is a bit of a WTF? to me ... It could also be the reason
why the "var value = arr[item]" assignment sometimes fails (on specific
"item" fields).


The new question now is : is there a way with which I can convince a
WeakList to accept the FF object ? Without trying to alter the FF object
itself ofcourse.

Regards,
Rudy Wieser


0 new messages