This queue is for tickets about the WWW-Mechanize-FireFox CPAN distribution.

Report information
The Basics
Id:
84418
Status:
resolved
Priority:
Low/Low

People
Owner:
Nobody in particular
Requestors:
GYPARK [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
0.71
Fixed in:
(no value)



Subject: tab doesn't close when there are multiple windows
Hello, At first, thank you for your great module. It is very helpful to me and I really love it. I found a problem that tab doesn't close automatically when the tab has opened in...other than the first window. I'm not good at English so I made a illustration and attached it. I wish it would be helpful for you in reproducing the problem. Firefox in my screenshot is Korean version but it would not matter, maybe. And, I have no idea whether this is an issue of this module or of MozRepl. If it is case of the latter, I'm sorry for bothering you. Would you please check it? Thank you. G.Y.Park from South Korea
Subject: tab_problem.png
tab_problem.png
I forgot reporting what my script was. It was just a very simple script: use WWW::Mechanize::Firefox; my $fox = WWW::Mechanize::Firefox->new(); $fox->get('http://google.com'); exit; G.Y.Park On Thu Apr 04 01:26:47 2013, GYPARK wrote:
Show quoted text
> Hello, > > At first, thank you for your great module. > It is very helpful to me and I really love it. > > I found a problem that tab doesn't close automatically > when the tab has opened in...other than the first window. > > I'm not good at English so I made a illustration and attached it. > I wish it would be helpful for you in reproducing the problem. > Firefox in my screenshot is Korean version but it would not matter, maybe. > > > And, I have no idea whether this is an issue of this module or of MozRepl. > If it is case of the latter, I'm sorry for bothering you. > > Would you please check it? > > > Thank you. > G.Y.Park from South Korea
Subject: Re: [rt.cpan.org #84418] tab doesn't close when there are multiple windows
Date: Mon, 08 Apr 2013 19:01:29 +0200
To: bug-WWW-Mechanize-FireFox@rt.cpan.org
From: Max Maischein <corion@cpan.org>
Hello Geunyoung Park! Actually, WWW::Mechanize::Firefox can remove the tab even from a different window, since about v 0.50 or so. The problem is that at the end of the script, Perl has already shut down the socket connection to Firefox, and so Perl cannot talk to Firefox anymore. The workaround is to explicitly release Firefox before your program ends: perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef $mech" ... or in your test program: use WWW::Mechanize::Firefox; my $fox= WWW::Mechanize::Firefox->new(); $fox->get('http://google.com'); undef $fox; exit; -max Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
Show quoted text
> Queue: WWW-Mechanize-FireFox > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > I forgot reporting what my script was. > > It was just a very simple script: > > use WWW::Mechanize::Firefox; > my $fox = WWW::Mechanize::Firefox->new(); > $fox->get('http://google.com'); > exit; > > > G.Y.Park > > > > On Thu Apr 04 01:26:47 2013, GYPARK wrote:
>> Hello, >> >> At first, thank you for your great module. >> It is very helpful to me and I really love it. >> >> I found a problem that tab doesn't close automatically >> when the tab has opened in...other than the first window. >> >> I'm not good at English so I made a illustration and attached it. >> I wish it would be helpful for you in reproducing the problem. >> Firefox in my screenshot is Korean version but it would not matter, maybe. >> >> >> And, I have no idea whether this is an issue of this module or of MozRepl. >> If it is case of the latter, I'm sorry for bothering you. >> >> Would you please check it? >> >> >> Thank you. >> G.Y.Park from South Korea
> > >
Hello, Thank you for your reply. I tried undef $fox; but it didn't work. I inserted sleep() before and after undef statement, but it also didn't work. Finally, I tried such code: # close tab explicitly $fox->application()->closeTab( $fox->tab() ); This code worked well with one window (or, running in first window of two) But when the script runs in the second window, that line resulted in an error: MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebProgress.removeProgressListener] at D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line 159 G.Y.Park On Mon Apr 08 13:01:57 2013, CORION wrote:
Show quoted text
> Hello Geunyoung Park! > > Actually, WWW::Mechanize::Firefox can remove the tab even from a > different window, since about v 0.50 or so. The problem is that at the > end of the script, Perl has already shut down the socket connection to > Firefox, and so Perl cannot talk to Firefox anymore. > > The workaround is to explicitly release Firefox before your program > ends: > > perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef $mech" > > ... or in your test program: > > use WWW::Mechanize::Firefox; > my $fox= WWW::Mechanize::Firefox->new(); > $fox->get('http://google.com'); > undef $fox; > exit; > > -max > > Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
> > Queue: WWW-Mechanize-FireFox > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > > > I forgot reporting what my script was. > > > > It was just a very simple script: > > > > use WWW::Mechanize::Firefox; > > my $fox = WWW::Mechanize::Firefox->new(); > > $fox->get('http://google.com'); > > exit; > > > > > > G.Y.Park > > > > > > > > On Thu Apr 04 01:26:47 2013, GYPARK wrote:
> >> Hello, > >> > >> At first, thank you for your great module. > >> It is very helpful to me and I really love it. > >> > >> I found a problem that tab doesn't close automatically > >> when the tab has opened in...other than the first window. > >> > >> I'm not good at English so I made a illustration and attached it. > >> I wish it would be helpful for you in reproducing the problem. > >> Firefox in my screenshot is Korean version but it would not matter,
> maybe.
> >> > >> > >> And, I have no idea whether this is an issue of this module or of
> MozRepl.
> >> If it is case of the latter, I'm sorry for bothering you. > >> > >> Would you please check it? > >> > >> > >> Thank you. > >> G.Y.Park from South Korea
> > > > > >
>
Subject: Re: [rt.cpan.org #84418] tab doesn't close when there are multiple windows
Date: Wed, 10 Apr 2013 22:15:10 +0200
To: bug-WWW-Mechanize-FireFox@rt.cpan.org
From: Max Maischein <corion@cpan.org>
Hello again, thanks for finding out how to more easily reproduce the error. I was now able to always reproduce the error. With the following changed subroutine ->closeTab(), I always get a properly closed tab, no matter which window is active at closing time: sub closeTab { my ($self,$tab,$repl) = @_; $repl ||= $self->repl; my $close_tab = $repl->declare(<<'JS'); function(tab) { if(tab.collapsed) { return }; var be = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator) .getEnumerator("navigator:browser"); while (be.hasMoreElements()) { var browserWin = be.getNext(); var tabbrowser = browserWin.gBrowser; if( tabbrowser ) { for( var i=0; i< tabbrowser.tabs.length; i++) { if( tabbrowser.tabs.item( i ) === tab ) { tabbrowser.removeTab(tab); break; }; }; }; }; } JS return $close_tab->($tab); } The changed version works for me on Firefox 20 and I'm currently running the test suite for the other browser versions. Can you please test whether this change also works for your cases? If so, I will release a new version. -max Am 09.04.2013 08:34, schrieb Geunyoung Park via RT:
Show quoted text
> Queue: WWW-Mechanize-FireFox > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > Hello, > > Thank you for your reply. > > I tried > undef $fox; > but it didn't work. > > I inserted sleep() before and after undef statement, but it also > didn't work. > > > Finally, I tried such code: > > # close tab explicitly > $fox->application()->closeTab( $fox->tab() ); > > This code worked well with one window (or, running in first window of two) > But when the script runs in the second window, that line resulted in an > error: > > MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIWebProgress.removeProgressListener] at D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line 159 > > > > > G.Y.Park > > > > On Mon Apr 08 13:01:57 2013, CORION wrote:
>> Hello Geunyoung Park! >> >> Actually, WWW::Mechanize::Firefox can remove the tab even from a >> different window, since about v 0.50 or so. The problem is that at the >> end of the script, Perl has already shut down the socket connection to >> Firefox, and so Perl cannot talk to Firefox anymore. >> >> The workaround is to explicitly release Firefox before your program >> ends: >> >> perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef $mech" >> >> ... or in your test program: >> >> use WWW::Mechanize::Firefox; >> my $fox= WWW::Mechanize::Firefox->new(); >> $fox->get('http://google.com'); >> undef $fox; >> exit; >> >> -max >> >> Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
>>> Queue: WWW-Mechanize-FireFox >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > >>> >>> I forgot reporting what my script was. >>> >>> It was just a very simple script: >>> >>> use WWW::Mechanize::Firefox; >>> my $fox = WWW::Mechanize::Firefox->new(); >>> $fox->get('http://google.com'); >>> exit; >>> >>> >>> G.Y.Park >>> >>> >>> >>> On Thu Apr 04 01:26:47 2013, GYPARK wrote:
>>>> Hello, >>>> >>>> At first, thank you for your great module. >>>> It is very helpful to me and I really love it. >>>> >>>> I found a problem that tab doesn't close automatically >>>> when the tab has opened in...other than the first window. >>>> >>>> I'm not good at English so I made a illustration and attached it. >>>> I wish it would be helpful for you in reproducing the problem. >>>> Firefox in my screenshot is Korean version but it would not matter,
>> maybe.
>>>> >>>> >>>> And, I have no idea whether this is an issue of this module or of
>> MozRepl.
>>>> If it is case of the latter, I'm sorry for bothering you. >>>> >>>> Would you please check it? >>>> >>>> >>>> Thank you. >>>> G.Y.Park from South Korea
>>> >>> >>>
>>
> > >
Hello, I'm sorry my reply is late. I modified API40.pm and changed closeTab() as you'd written. I tested several times with various number of FF windows. (up to five) (My FF version is 20.0 and MozRepl extension is a patched version https://github.com/milouse/mozrepl/commit/3504aa5b45f4b438bc0e7ef53019558c4bd8bc1c ) This code: # close tab explicitly $fox->application()->closeTab( $fox->tab() ); worked very well in every time. Every tab was closed correctly. :-) On the other hand, undef $fox; or, to do nothing and exit(), these resulted in the problem as before. (sleep() before exit() didn't work) I wish my report to be helpful. G.Y.Park On Wed Apr 10 16:15:33 2013, CORION wrote:
Show quoted text
> Hello again, > > thanks for finding out how to more easily reproduce the error. I was > now > able to always reproduce the error. With the following changed > subroutine ->closeTab(), I always get a properly closed tab, no matter > which window is active at closing time: > > sub closeTab { > my ($self,$tab,$repl) = @_; > $repl ||= $self->repl; > my $close_tab = $repl->declare(<<'JS'); > function(tab) { > if(tab.collapsed) { return }; > var be = > Components.classes["@mozilla.org/appshell/window-mediator;1"] > .getService(Components.interfaces.nsIWindowMediator) > .getEnumerator("navigator:browser"); > while (be.hasMoreElements()) { > var browserWin = be.getNext(); > var tabbrowser = browserWin.gBrowser; > if( tabbrowser ) { > for( var i=0; i< tabbrowser.tabs.length; i++) { > if( tabbrowser.tabs.item( i ) === tab ) { > tabbrowser.removeTab(tab); > break; > }; > }; > }; > }; > } > JS > return $close_tab->($tab); > } > > The changed version works for me on Firefox 20 and I'm currently > running > the test suite for the other browser versions. > > Can you please test whether this change also works for your cases? If > so, I will release a new version. > > -max > > > Am 09.04.2013 08:34, schrieb Geunyoung Park via RT:
> > Queue: WWW-Mechanize-FireFox > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > > > Hello, > > > > Thank you for your reply. > > > > I tried > > undef $fox; > > but it didn't work. > > > > I inserted sleep() before and after undef statement, but it also > > didn't work. > > > > > > Finally, I tried such code: > > > > # close tab explicitly > > $fox->application()->closeTab( $fox->tab() ); > > > > This code worked well with one window (or, running in first window
> of two)
> > But when the script runs in the second window, that line resulted in
> an
> > error: > > > > MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned failure
> code: 0x80004005 (NS_ERROR_FAILURE) > [nsIWebProgress.removeProgressListener] at > D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line 159
> > > > > > > > > > G.Y.Park > > > > > > > > On Mon Apr 08 13:01:57 2013, CORION wrote:
> >> Hello Geunyoung Park! > >> > >> Actually, WWW::Mechanize::Firefox can remove the tab even from a > >> different window, since about v 0.50 or so. The problem is that at
> the
> >> end of the script, Perl has already shut down the socket connection
> to
> >> Firefox, and so Perl cannot talk to Firefox anymore. > >> > >> The workaround is to explicitly release Firefox before your program > >> ends: > >> > >> perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef
> $mech"
> >> > >> ... or in your test program: > >> > >> use WWW::Mechanize::Firefox; > >> my $fox= WWW::Mechanize::Firefox->new(); > >> $fox->get('http://google.com'); > >> undef $fox; > >> exit; > >> > >> -max > >> > >> Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
> >>> Queue: WWW-Mechanize-FireFox > >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > >>> > >>> I forgot reporting what my script was. > >>> > >>> It was just a very simple script: > >>> > >>> use WWW::Mechanize::Firefox; > >>> my $fox = WWW::Mechanize::Firefox->new(); > >>> $fox->get('http://google.com'); > >>> exit; > >>> > >>> > >>> G.Y.Park > >>> > >>> > >>> > >>> On Thu Apr 04 01:26:47 2013, GYPARK wrote:
> >>>> Hello, > >>>> > >>>> At first, thank you for your great module. > >>>> It is very helpful to me and I really love it. > >>>> > >>>> I found a problem that tab doesn't close automatically > >>>> when the tab has opened in...other than the first window. > >>>> > >>>> I'm not good at English so I made a illustration and attached it. > >>>> I wish it would be helpful for you in reproducing the problem. > >>>> Firefox in my screenshot is Korean version but it would not
> matter,
> >> maybe.
> >>>> > >>>> > >>>> And, I have no idea whether this is an issue of this module or of
> >> MozRepl.
> >>>> If it is case of the latter, I'm sorry for bothering you. > >>>> > >>>> Would you please check it? > >>>> > >>>> > >>>> Thank you. > >>>> G.Y.Park from South Korea
> >>> > >>> > >>>
> >>
> > > > > >
>
Subject: Re: [rt.cpan.org #84418] tab doesn't close when there are multiple windows
Date: Thu, 11 Apr 2013 21:41:39 +0200
To: bug-WWW-Mechanize-FireFox@rt.cpan.org
From: Max Maischein <corion@cpan.org>
Hello again, it's great if the changed closeTab() works for you. If you also change the sub ->autoclose_tab() as below, it should all work. I've attached my test case for the regression tests too. Without the changes, I get 2 failed tests, and with the changes I get 6 passing tests. If you can reproduce the error before patching and the error goes away with the changes below, that would be fantastic. Also thank you very much for the hint of the patched MozRepl. I have just upgraded to Firefox 20, with the changes from github. It seems there is a fresh release of the Mozrepl plugin at https://github.com/bard/mozrepl incorporating these changes. -max sub closeTab { my ($self,$tab,$repl) = @_; $repl ||= $self->repl; my $close_tab = $repl->declare(<<'JS'); function(tab) { if(tab.collapsed) { return }; var be = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator) .getEnumerator("navigator:browser"); while (be.hasMoreElements()) { var browserWin = be.getNext(); var tabbrowser = browserWin.gBrowser; if( tabbrowser ) { for( var i=0; i< tabbrowser.tabs.length; i++) { if( tabbrowser.tabs.item( i ) === tab ) { tabbrowser.removeTab(tab); break; }; }; }; }; } JS return $close_tab->($tab); } sub autoclose_tab { my ($self,$tab,$close) = @_; $close = 1 if( 2 == @_ ); my $release = join "\n", # Find the window our tab lives in q<if(!self.collapsed){>, q<var be = Components.classes["@mozilla.org/appshell/window-mediator;1"]>, q<.getService(Components.interfaces.nsIWindowMediator)>, q<.getEnumerator("navigator:browser");>, q<while (be.hasMoreElements()) {>, q<var browserWin = be.getNext();>, q<var tabbrowser = browserWin.gBrowser;>, q<if( tabbrowser ) {>, q!for( var i=0; i< tabbrowser.tabs.length; i++) {!, q<if( tabbrowser.tabs.item( i ) === self ) {>, q<tabbrowser.removeTab(self);>, q<break;>, q<};>, q<};>, q<};>, q<};>, q<};>, ; if( $close ) { $tab->__release_action($release); } else { $tab->__release_action(''); }; }; Am 11.04.2013 18:27, schrieb Geunyoung Park via RT:
Show quoted text
> Queue: WWW-Mechanize-FireFox > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > Hello, > > I'm sorry my reply is late. > > > I modified API40.pm and changed closeTab() as you'd written. > > I tested several times with various number of FF windows. (up to five) > (My FF version is 20.0 and MozRepl extension is a patched version > https://github.com/milouse/mozrepl/commit/3504aa5b45f4b438bc0e7ef53019558c4bd8bc1c ) > > > This code: > # close tab explicitly > $fox->application()->closeTab( $fox->tab() ); > worked very well in every time. > Every tab was closed correctly. :-) > > > On the other hand, > undef $fox; > or, to do nothing and exit(), > these resulted in the problem as before. > (sleep() before exit() didn't work) > > > I wish my report to be helpful. > > G.Y.Park > > > > On Wed Apr 10 16:15:33 2013, CORION wrote:
>> Hello again, >> >> thanks for finding out how to more easily reproduce the error. I was >> now >> able to always reproduce the error. With the following changed >> subroutine ->closeTab(), I always get a properly closed tab, no matter >> which window is active at closing time: >> >> sub closeTab { >> my ($self,$tab,$repl) = @_; >> $repl ||= $self->repl; >> my $close_tab = $repl->declare(<<'JS'); >> function(tab) { >> if(tab.collapsed) { return }; >> var be = >> Components.classes["@mozilla.org/appshell/window-mediator;1"] >> .getService(Components.interfaces.nsIWindowMediator) >> .getEnumerator("navigator:browser"); >> while (be.hasMoreElements()) { >> var browserWin = be.getNext(); >> var tabbrowser = browserWin.gBrowser; >> if( tabbrowser ) { >> for( var i=0; i< tabbrowser.tabs.length; i++) { >> if( tabbrowser.tabs.item( i ) === tab ) { >> tabbrowser.removeTab(tab); >> break; >> }; >> }; >> }; >> }; >> } >> JS >> return $close_tab->($tab); >> } >> >> The changed version works for me on Firefox 20 and I'm currently >> running >> the test suite for the other browser versions. >> >> Can you please test whether this change also works for your cases? If >> so, I will release a new version. >> >> -max >> >> >> Am 09.04.2013 08:34, schrieb Geunyoung Park via RT:
>>> Queue: WWW-Mechanize-FireFox >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > >>> >>> Hello, >>> >>> Thank you for your reply. >>> >>> I tried >>> undef $fox; >>> but it didn't work. >>> >>> I inserted sleep() before and after undef statement, but it also >>> didn't work. >>> >>> >>> Finally, I tried such code: >>> >>> # close tab explicitly >>> $fox->application()->closeTab( $fox->tab() ); >>> >>> This code worked well with one window (or, running in first window
>> of two)
>>> But when the script runs in the second window, that line resulted in
>> an
>>> error: >>> >>> MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned failure
>> code: 0x80004005 (NS_ERROR_FAILURE) >> [nsIWebProgress.removeProgressListener] at >> D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line 159
>>> >>> >>> >>> >>> G.Y.Park >>> >>> >>> >>> On Mon Apr 08 13:01:57 2013, CORION wrote:
>>>> Hello Geunyoung Park! >>>> >>>> Actually, WWW::Mechanize::Firefox can remove the tab even from a >>>> different window, since about v 0.50 or so. The problem is that at
>> the
>>>> end of the script, Perl has already shut down the socket connection
>> to
>>>> Firefox, and so Perl cannot talk to Firefox anymore. >>>> >>>> The workaround is to explicitly release Firefox before your program >>>> ends: >>>> >>>> perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef
>> $mech"
>>>> >>>> ... or in your test program: >>>> >>>> use WWW::Mechanize::Firefox; >>>> my $fox= WWW::Mechanize::Firefox->new(); >>>> $fox->get('http://google.com'); >>>> undef $fox; >>>> exit; >>>> >>>> -max >>>> >>>> Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
>>>>> Queue: WWW-Mechanize-FireFox >>>>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > >>>>> >>>>> I forgot reporting what my script was. >>>>> >>>>> It was just a very simple script: >>>>> >>>>> use WWW::Mechanize::Firefox; >>>>> my $fox = WWW::Mechanize::Firefox->new(); >>>>> $fox->get('http://google.com'); >>>>> exit; >>>>> >>>>> >>>>> G.Y.Park >>>>> >>>>> >>>>> >>>>> On Thu Apr 04 01:26:47 2013, GYPARK wrote:
>>>>>> Hello, >>>>>> >>>>>> At first, thank you for your great module. >>>>>> It is very helpful to me and I really love it. >>>>>> >>>>>> I found a problem that tab doesn't close automatically >>>>>> when the tab has opened in...other than the first window. >>>>>> >>>>>> I'm not good at English so I made a illustration and attached it. >>>>>> I wish it would be helpful for you in reproducing the problem. >>>>>> Firefox in my screenshot is Korean version but it would not
>> matter,
>>>> maybe.
>>>>>> >>>>>> >>>>>> And, I have no idea whether this is an issue of this module or of
>>>> MozRepl.
>>>>>> If it is case of the latter, I'm sorry for bothering you. >>>>>> >>>>>> Would you please check it? >>>>>> >>>>>> >>>>>> Thank you. >>>>>> G.Y.Park from South Korea
>>>>> >>>>> >>>>>
>>>>
>>> >>> >>>
>>
> > >

Message body is not shown because sender requested not to inline it.

Hello, I tried this new change and I couldn't find any case that the error occurred again. :-) Now I don't need explicit closeTab() nor undef(). My first simple script works very well with mutiple windows. When the script exits, (of course I don't need even exit()) the tab closes perfectly. Thank you very much for your effort. and thanks again for this fantastic module. G.Y.Park On Thu Apr 11 15:42:08 2013, CORION wrote:
Show quoted text
> Hello again, > > it's great if the changed closeTab() works for you. If you also change > the sub ->autoclose_tab() as below, it should all work. I've attached > my > test case for the regression tests too. Without the changes, I get 2 > failed tests, and with the changes I get 6 passing tests. If you can > reproduce the error before patching and the error goes away with the > changes below, that would be fantastic. > > Also thank you very much for the hint of the patched MozRepl. I have > just upgraded to Firefox 20, with the changes from github. It seems > there is a fresh release of the Mozrepl plugin at > https://github.com/bard/mozrepl incorporating these changes. > > -max > > sub closeTab { > my ($self,$tab,$repl) = @_; > $repl ||= $self->repl; > my $close_tab = $repl->declare(<<'JS'); > function(tab) { > if(tab.collapsed) { return }; > var be = > Components.classes["@mozilla.org/appshell/window-mediator;1"] > .getService(Components.interfaces.nsIWindowMediator) > .getEnumerator("navigator:browser"); > while (be.hasMoreElements()) { > var browserWin = be.getNext(); > var tabbrowser = browserWin.gBrowser; > if( tabbrowser ) { > for( var i=0; i< tabbrowser.tabs.length; i++) { > if( tabbrowser.tabs.item( i ) === tab ) { > tabbrowser.removeTab(tab); > break; > }; > }; > }; > }; > } > JS > return $close_tab->($tab); > } > > sub autoclose_tab { > my ($self,$tab,$close) = @_; > $close = 1 > if( 2 == @_ ); > my $release = join "\n", > # Find the window our tab lives in > q<if(!self.collapsed){>, > q<var be = > Components.classes["@mozilla.org/appshell/window-mediator;1"]>, > > q<.getService(Components.interfaces.nsIWindowMediator)>, > q<.getEnumerator("navigator:browser");>, > q<while (be.hasMoreElements()) {>, > q<var browserWin = be.getNext();>, > q<var tabbrowser = browserWin.gBrowser;>, > q<if( tabbrowser ) {>, > q!for( var i=0; i< tabbrowser.tabs.length; i++) {!, > q<if( tabbrowser.tabs.item( i ) === self ) {>, > q<tabbrowser.removeTab(self);>, > q<break;>, > q<};>, > q<};>, > q<};>, > q<};>, > q<};>, > ; > if( $close ) { > $tab->__release_action($release); > } else { > $tab->__release_action(''); > }; > }; > > > Am 11.04.2013 18:27, schrieb Geunyoung Park via RT:
> > Queue: WWW-Mechanize-FireFox > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > > > Hello, > > > > I'm sorry my reply is late. > > > > > > I modified API40.pm and changed closeTab() as you'd written. > > > > I tested several times with various number of FF windows. (up to
> five)
> > (My FF version is 20.0 and MozRepl extension is a patched version > >
> https://github.com/milouse/mozrepl/commit/3504aa5b45f4b438bc0e7ef53019558c4bd8bc1c > )
> > > > > > This code: > > # close tab explicitly > > $fox->application()->closeTab( $fox->tab() ); > > worked very well in every time. > > Every tab was closed correctly. :-) > > > > > > On the other hand, > > undef $fox; > > or, to do nothing and exit(), > > these resulted in the problem as before. > > (sleep() before exit() didn't work) > > > > > > I wish my report to be helpful. > > > > G.Y.Park > > > > > > > > On Wed Apr 10 16:15:33 2013, CORION wrote:
> >> Hello again, > >> > >> thanks for finding out how to more easily reproduce the error. I
> was
> >> now > >> able to always reproduce the error. With the following changed > >> subroutine ->closeTab(), I always get a properly closed tab, no
> matter
> >> which window is active at closing time: > >> > >> sub closeTab { > >> my ($self,$tab,$repl) = @_; > >> $repl ||= $self->repl; > >> my $close_tab = $repl->declare(<<'JS'); > >> function(tab) { > >> if(tab.collapsed) { return }; > >> var be = > >> Components.classes["@mozilla.org/appshell/window-mediator;1"] > >>
> .getService(Components.interfaces.nsIWindowMediator)
> >> .getEnumerator("navigator:browser"); > >> while (be.hasMoreElements()) { > >> var browserWin = be.getNext(); > >> var tabbrowser = browserWin.gBrowser; > >> if( tabbrowser ) { > >> for( var i=0; i< tabbrowser.tabs.length; i++) { > >> if( tabbrowser.tabs.item( i ) === tab ) { > >> tabbrowser.removeTab(tab); > >> break; > >> }; > >> }; > >> }; > >> }; > >> } > >> JS > >> return $close_tab->($tab); > >> } > >> > >> The changed version works for me on Firefox 20 and I'm currently > >> running > >> the test suite for the other browser versions. > >> > >> Can you please test whether this change also works for your cases?
> If
> >> so, I will release a new version. > >> > >> -max > >> > >> > >> Am 09.04.2013 08:34, schrieb Geunyoung Park via RT:
> >>> Queue: WWW-Mechanize-FireFox > >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > >>> > >>> Hello, > >>> > >>> Thank you for your reply. > >>> > >>> I tried > >>> undef $fox; > >>> but it didn't work. > >>> > >>> I inserted sleep() before and after undef statement, but it also > >>> didn't work. > >>> > >>> > >>> Finally, I tried such code: > >>> > >>> # close tab explicitly > >>> $fox->application()->closeTab( $fox->tab() ); > >>> > >>> This code worked well with one window (or, running in first window
> >> of two)
> >>> But when the script runs in the second window, that line resulted
> in
> >> an
> >>> error: > >>> > >>> MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned
> failure
> >> code: 0x80004005 (NS_ERROR_FAILURE) > >> [nsIWebProgress.removeProgressListener] at > >> D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line
> 159
> >>> > >>> > >>> > >>> > >>> G.Y.Park > >>> > >>> > >>> > >>> On Mon Apr 08 13:01:57 2013, CORION wrote:
> >>>> Hello Geunyoung Park! > >>>> > >>>> Actually, WWW::Mechanize::Firefox can remove the tab even from a > >>>> different window, since about v 0.50 or so. The problem is that
> at
> >> the
> >>>> end of the script, Perl has already shut down the socket
> connection
> >> to
> >>>> Firefox, and so Perl cannot talk to Firefox anymore. > >>>> > >>>> The workaround is to explicitly release Firefox before your
> program
> >>>> ends: > >>>> > >>>> perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef
> >> $mech"
> >>>> > >>>> ... or in your test program: > >>>> > >>>> use WWW::Mechanize::Firefox; > >>>> my $fox= WWW::Mechanize::Firefox->new(); > >>>> $fox->get('http://google.com'); > >>>> undef $fox; > >>>> exit; > >>>> > >>>> -max > >>>> > >>>> Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
> >>>>> Queue: WWW-Mechanize-FireFox > >>>>> Ticket <URL:
> https://rt.cpan.org/Ticket/Display.html?id=84418 >
> >>>>> > >>>>> I forgot reporting what my script was. > >>>>> > >>>>> It was just a very simple script: > >>>>> > >>>>> use WWW::Mechanize::Firefox; > >>>>> my $fox = WWW::Mechanize::Firefox->new(); > >>>>> $fox->get('http://google.com'); > >>>>> exit; > >>>>> > >>>>> > >>>>> G.Y.Park > >>>>> > >>>>> > >>>>> > >>>>> On Thu Apr 04 01:26:47 2013, GYPARK wrote:
> >>>>>> Hello, > >>>>>> > >>>>>> At first, thank you for your great module. > >>>>>> It is very helpful to me and I really love it. > >>>>>> > >>>>>> I found a problem that tab doesn't close automatically > >>>>>> when the tab has opened in...other than the first window. > >>>>>> > >>>>>> I'm not good at English so I made a illustration and attached
> it.
> >>>>>> I wish it would be helpful for you in reproducing the problem. > >>>>>> Firefox in my screenshot is Korean version but it would not
> >> matter,
> >>>> maybe.
> >>>>>> > >>>>>> > >>>>>> And, I have no idea whether this is an issue of this module or
> of
> >>>> MozRepl.
> >>>>>> If it is case of the latter, I'm sorry for bothering you. > >>>>>> > >>>>>> Would you please check it? > >>>>>> > >>>>>> > >>>>>> Thank you. > >>>>>> G.Y.Park from South Korea
> >>>>> > >>>>> > >>>>>
> >>>>
> >>> > >>> > >>>
> >>
> > > > > >
>
Subject: Re: [rt.cpan.org #84418] tab doesn't close when there are multiple windows
Date: Fri, 12 Apr 2013 21:05:28 +0200
To: bug-WWW-Mechanize-FireFox@rt.cpan.org
From: Max Maischein <corion@cpan.org>
Hi again, I've just released v0.72 with this fix Thanks again for reporting and testing! -max Am 12.04.2013 03:48, schrieb Geunyoung Park via RT:
Show quoted text
> Queue: WWW-Mechanize-FireFox > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > > > Hello, > > > I tried this new change and I couldn't find any case that > the error occurred again. :-) > > Now I don't need explicit closeTab() nor undef(). > My first simple script works very well with mutiple windows. > When the script exits, (of course I don't need even exit()) > the tab closes perfectly. > > Thank you very much for your effort. > and thanks again for this fantastic module. > > G.Y.Park > > > > > > On Thu Apr 11 15:42:08 2013, CORION wrote:
>> Hello again, >> >> it's great if the changed closeTab() works for you. If you also change >> the sub ->autoclose_tab() as below, it should all work. I've attached >> my >> test case for the regression tests too. Without the changes, I get 2 >> failed tests, and with the changes I get 6 passing tests. If you can >> reproduce the error before patching and the error goes away with the >> changes below, that would be fantastic. >> >> Also thank you very much for the hint of the patched MozRepl. I have >> just upgraded to Firefox 20, with the changes from github. It seems >> there is a fresh release of the Mozrepl plugin at >> https://github.com/bard/mozrepl incorporating these changes. >> >> -max >> >> sub closeTab { >> my ($self,$tab,$repl) = @_; >> $repl ||= $self->repl; >> my $close_tab = $repl->declare(<<'JS'); >> function(tab) { >> if(tab.collapsed) { return }; >> var be = >> Components.classes["@mozilla.org/appshell/window-mediator;1"] >> .getService(Components.interfaces.nsIWindowMediator) >> .getEnumerator("navigator:browser"); >> while (be.hasMoreElements()) { >> var browserWin = be.getNext(); >> var tabbrowser = browserWin.gBrowser; >> if( tabbrowser ) { >> for( var i=0; i< tabbrowser.tabs.length; i++) { >> if( tabbrowser.tabs.item( i ) === tab ) { >> tabbrowser.removeTab(tab); >> break; >> }; >> }; >> }; >> }; >> } >> JS >> return $close_tab->($tab); >> } >> >> sub autoclose_tab { >> my ($self,$tab,$close) = @_; >> $close = 1 >> if( 2 == @_ ); >> my $release = join "\n", >> # Find the window our tab lives in >> q<if(!self.collapsed){>, >> q<var be = >> Components.classes["@mozilla.org/appshell/window-mediator;1"]>, >> >> q<.getService(Components.interfaces.nsIWindowMediator)>, >> q<.getEnumerator("navigator:browser");>, >> q<while (be.hasMoreElements()) {>, >> q<var browserWin = be.getNext();>, >> q<var tabbrowser = browserWin.gBrowser;>, >> q<if( tabbrowser ) {>, >> q!for( var i=0; i< tabbrowser.tabs.length; i++) {!, >> q<if( tabbrowser.tabs.item( i ) === self ) {>, >> q<tabbrowser.removeTab(self);>, >> q<break;>, >> q<};>, >> q<};>, >> q<};>, >> q<};>, >> q<};>, >> ; >> if( $close ) { >> $tab->__release_action($release); >> } else { >> $tab->__release_action(''); >> }; >> }; >> >> >> Am 11.04.2013 18:27, schrieb Geunyoung Park via RT:
>>> Queue: WWW-Mechanize-FireFox >>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > >>> >>> Hello, >>> >>> I'm sorry my reply is late. >>> >>> >>> I modified API40.pm and changed closeTab() as you'd written. >>> >>> I tested several times with various number of FF windows. (up to
>> five)
>>> (My FF version is 20.0 and MozRepl extension is a patched version >>>
>> https://github.com/milouse/mozrepl/commit/3504aa5b45f4b438bc0e7ef53019558c4bd8bc1c >> )
>>> >>> >>> This code: >>> # close tab explicitly >>> $fox->application()->closeTab( $fox->tab() ); >>> worked very well in every time. >>> Every tab was closed correctly. :-) >>> >>> >>> On the other hand, >>> undef $fox; >>> or, to do nothing and exit(), >>> these resulted in the problem as before. >>> (sleep() before exit() didn't work) >>> >>> >>> I wish my report to be helpful. >>> >>> G.Y.Park >>> >>> >>> >>> On Wed Apr 10 16:15:33 2013, CORION wrote:
>>>> Hello again, >>>> >>>> thanks for finding out how to more easily reproduce the error. I
>> was
>>>> now >>>> able to always reproduce the error. With the following changed >>>> subroutine ->closeTab(), I always get a properly closed tab, no
>> matter
>>>> which window is active at closing time: >>>> >>>> sub closeTab { >>>> my ($self,$tab,$repl) = @_; >>>> $repl ||= $self->repl; >>>> my $close_tab = $repl->declare(<<'JS'); >>>> function(tab) { >>>> if(tab.collapsed) { return }; >>>> var be = >>>> Components.classes["@mozilla.org/appshell/window-mediator;1"] >>>>
>> .getService(Components.interfaces.nsIWindowMediator)
>>>> .getEnumerator("navigator:browser"); >>>> while (be.hasMoreElements()) { >>>> var browserWin = be.getNext(); >>>> var tabbrowser = browserWin.gBrowser; >>>> if( tabbrowser ) { >>>> for( var i=0; i< tabbrowser.tabs.length; i++) { >>>> if( tabbrowser.tabs.item( i ) === tab ) { >>>> tabbrowser.removeTab(tab); >>>> break; >>>> }; >>>> }; >>>> }; >>>> }; >>>> } >>>> JS >>>> return $close_tab->($tab); >>>> } >>>> >>>> The changed version works for me on Firefox 20 and I'm currently >>>> running >>>> the test suite for the other browser versions. >>>> >>>> Can you please test whether this change also works for your cases?
>> If
>>>> so, I will release a new version. >>>> >>>> -max >>>> >>>> >>>> Am 09.04.2013 08:34, schrieb Geunyoung Park via RT:
>>>>> Queue: WWW-Mechanize-FireFox >>>>> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84418 > >>>>> >>>>> Hello, >>>>> >>>>> Thank you for your reply. >>>>> >>>>> I tried >>>>> undef $fox; >>>>> but it didn't work. >>>>> >>>>> I inserted sleep() before and after undef statement, but it also >>>>> didn't work. >>>>> >>>>> >>>>> Finally, I tried such code: >>>>> >>>>> # close tab explicitly >>>>> $fox->application()->closeTab( $fox->tab() ); >>>>> >>>>> This code worked well with one window (or, running in first window
>>>> of two)
>>>>> But when the script runs in the second window, that line resulted
>> in
>>>> an
>>>>> error: >>>>> >>>>> MozRepl::RemoteObject: NS_ERROR_FAILURE: Component returned
>> failure
>>>> code: 0x80004005 (NS_ERROR_FAILURE) >>>> [nsIWebProgress.removeProgressListener] at >>>> D:/strawberry/perl/site/lib/Firefox/Application/API40.pm line
>> 159
>>>>> >>>>> >>>>> >>>>> >>>>> G.Y.Park >>>>> >>>>> >>>>> >>>>> On Mon Apr 08 13:01:57 2013, CORION wrote:
>>>>>> Hello Geunyoung Park! >>>>>> >>>>>> Actually, WWW::Mechanize::Firefox can remove the tab even from a >>>>>> different window, since about v 0.50 or so. The problem is that
>> at
>>>> the
>>>>>> end of the script, Perl has already shut down the socket
>> connection
>>>> to
>>>>>> Firefox, and so Perl cannot talk to Firefox anymore. >>>>>> >>>>>> The workaround is to explicitly release Firefox before your
>> program
>>>>>> ends: >>>>>> >>>>>> perl -Ilib -MWWW::Mechanize::Firefox::DSL -e "sleep 5; undef
>>>> $mech"
>>>>>> >>>>>> ... or in your test program: >>>>>> >>>>>> use WWW::Mechanize::Firefox; >>>>>> my $fox= WWW::Mechanize::Firefox->new(); >>>>>> $fox->get('http://google.com'); >>>>>> undef $fox; >>>>>> exit; >>>>>> >>>>>> -max >>>>>> >>>>>> Am 04.04.2013 07:29, schrieb Geunyoung Park via RT:
>>>>>>> Queue: WWW-Mechanize-FireFox >>>>>>> Ticket <URL:
>> https://rt.cpan.org/Ticket/Display.html?id=84418 >
>>>>>>> >>>>>>> I forgot reporting what my script was. >>>>>>> >>>>>>> It was just a very simple script: >>>>>>> >>>>>>> use WWW::Mechanize::Firefox; >>>>>>> my $fox = WWW::Mechanize::Firefox->new(); >>>>>>> $fox->get('http://google.com'); >>>>>>> exit; >>>>>>> >>>>>>> >>>>>>> G.Y.Park >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Thu Apr 04 01:26:47 2013, GYPARK wrote:
>>>>>>>> Hello, >>>>>>>> >>>>>>>> At first, thank you for your great module. >>>>>>>> It is very helpful to me and I really love it. >>>>>>>> >>>>>>>> I found a problem that tab doesn't close automatically >>>>>>>> when the tab has opened in...other than the first window. >>>>>>>> >>>>>>>> I'm not good at English so I made a illustration and attached
>> it.
>>>>>>>> I wish it would be helpful for you in reproducing the problem. >>>>>>>> Firefox in my screenshot is Korean version but it would not
>>>> matter,
>>>>>> maybe.
>>>>>>>> >>>>>>>> >>>>>>>> And, I have no idea whether this is an issue of this module or
>> of
>>>>>> MozRepl.
>>>>>>>> If it is case of the latter, I'm sorry for bothering you. >>>>>>>> >>>>>>>> Would you please check it? >>>>>>>> >>>>>>>> >>>>>>>> Thank you. >>>>>>>> G.Y.Park from South Korea
>>>>>>> >>>>>>> >>>>>>>
>>>>>>
>>>>> >>>>> >>>>>
>>>>
>>> >>> >>>
>>
> > >


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.