sugarlabs / browse-activity

Sugar activity to browse the internet; WebKit on GTK on Sugar Toolkit
GNU General Public License v2.0
8 stars 44 forks source link

Search in address bar is redirecting to website's search plugin #86

Open avinashbharti97 opened 5 years ago

avinashbharti97 commented 5 years ago

Subject of the Issue On visiting https://www.sugarlabs.org using Browse-activity and then using the Address bar if any keyword search is performed then the address redirects to website's search plugin instead of normal google search.

Test Environment

Steps to reproduce

Expected Behaviour

Actual Behaviour

quozl commented 5 years ago

Isn't this how it was designed and always worked? Why is that behaviour not expected?

avinashbharti97 commented 5 years ago

Providing link manually in the address bar also leads to website's search plugin. This behavior is not only limited to keywords but links also :) .

quozl commented 5 years ago

I'm waiting for https://sugarlabs.org/ to return to normal service before I test this, but I think this behaviour is normal and expected for the Browse activity.

avinashbharti97 commented 5 years ago

If this behavior is normal then I would not like this issue to be tested. I did a wrong analyse of UX, So I am closing this issue :blush: Thanks

quozl commented 5 years ago

I want my opinion tested. Is it coded to do this, or is it accidental? If it is not coded, why is it happening?

rhl-bthr commented 5 years ago

This was discussed in https://github.com/sugarlabs/browse-activity/issues/78#issuecomment-375423740 and further comments

quozl commented 5 years ago

I see, thanks. Good memory. Mine was vague. @avinashbharti97, are you testing with the latest commit in Browse, or with a pre-installed Browse activity from Ubuntu 18.04?

avinashbharti97 commented 5 years ago

Yes, I am testing with the latest commit. Though both the previous and current issue looks same but I think both are different, Once sugarlabs.org will be live I will test this thoroughly and explain the behaviour again.

quozl commented 5 years ago

Good, thanks. I'm also waiting for https://sugarlabs.org/ to return to normal service before I test this. If you know of another web site that triggers the behaviour, let me know.

tony37 commented 5 years ago

What is expected behavior of Browse when not connected to the internet, e.g. to a local server? With internet service available here, any reference to Google can cause a delay of minutes.

quozl commented 5 years ago

Tested Browse-157.4 on Fedora 18, and Browse-202 on Ubuntu 18.04. Behaviour as discussed above does reproduce in both cases;

So the behaviour is not defined by Browse, but by https://sugarlabs.org/, therefore it is appropriate for this issue in Browse to remain closed.

Aniket21mathur commented 5 years ago

The Issue can be closed. Thanks!

quozl commented 5 years ago

Thanks. I've had second thoughts. Could others please review what I've found;

--- /tmp/www/index.html.orig    2019-04-01 16:23:36.256210011 +1100
+++ /tmp/www/index.html 2019-04-01 16:24:09.271768336 +1100
@@ -112,12 +112,6 @@
                var re = document.getElementById("SearchBar").value;
                document.getElementById("searchLink").href = "/search/?q=" + re;
        };
-       document.addEventListener('keyup', function(ev) {
-               if( ev.keyCode == 13 ) {
-                       var re = document.getElementById("SearchBar").value;
-                       document.getElementById("searchLink").href = "/search/?q=" + re;
-                       document.getElementById("searchLink").click();}
-       });
        function expander(){
         if(window.innerWidth > 767){
             document.getElementById("searchForm").style.width="53%";

This means that pressing enter in the URL entry box is executing JavaScript provided by the web page.

How is it that the WebKit2.WebView object is receiving key release events that should have been private to the Browse URL entry box?

nswarup14 commented 5 years ago

@quozl Where is the file that you have shown found?. For www.sugarlabs.org source code, I found a file in /includes/nav.html, or am I talking about the wrong file?

Thanks

quozl commented 5 years ago

There's multiple files involved. I used wget to fetch index.html from the web server. The web server does not transmit the unchanged source.

index.html is the template source file from which the index.html file is built. Line 5 includes nav.html.

So it seems likely you have found the right file.

quozl commented 5 years ago

But the file should not be changed. The fault is with Browse; it should not be forwarding key release events from the URL entry box to the WebView object. Other browsers don't do this.

rhl-bthr commented 5 years ago

The fault is with Browse;

+1; Websites should not be able to take over the browser's expected behavior without asking for permissions

nswarup14 commented 5 years ago

@quozl @pro-panda @chimosky Is there any way to detect the key release events that are being forwarded?

I did a lot of testing on the issue, but I'm unable to pinpoint the source of the issue exactly.

press enter; the Google Search is begun, the entry briefly contains a Google URL, then Google issues a redirect to https://sugarlabs.org/search/?q=, and the Sugar Labs search page is shown,

The link is not being redirected. I was able to verify this by printing out the status of the load operation in the __load_changed_cb of browser.py. WebKit2.LoadEvent.REDIRECTED is never passed. Rather the google search ends abruptly and a new load operation is begun with the new active URL of https://sugarlabs.org/search/?q=hello

I would really like some guidance on how to proceed.

Thanks!

quozl commented 5 years ago

Thanks for asking.

Yes, that's the result of the JavaScript code on the web site being executed in response to the enter key release event.

However, the problem is that the enter key release event should not have been handed over to the WebKit2.WebView widget.

You could experiment with source code. WebView parent classes include Gtk.Container and Gtk.Widget, so you could capture the key-press-event signal. You could examine source code. WebView class is in the WebKit sources. The GTK widgets are in the GTK sources.

However, it may be simpler to think about the problem entirely differently. Does it happen on other WebKit and GTK browsers? Yes, it does.

sudo apt install epiphany-browser
epiphany-browser https://sugarlabs.org/

So instead of fixing it in Browse, we could log a bug to say that Epiphany (because of WebKit) can be prevented from doing a conventional search by redirecting the user to a crafted web page that contains a JavaScript key handler. This may be more serious than it looks! :grin:

I suggest you search Epiphany or WebKit GTK bugs.

Looking back, it was a mistake to assume that the problem is the fault of code in Browse, just because the issue was logged against Browse.

p.s. this is still activity maintenance; we often have to fix or work around problems in other code than our own.