Fixing a Bug, Adding Tests

In this lab, we were asked to work on the Brave browser, but more specifically to see how it compares to other browsers in certain niche tests. To do this, we studied the testing code for the Brave browser to try to understand it at its base, compared to FireFox and Chrome as examples. Following this analysis, we would find some bugs or odd behaviour that Brave did but other browsers didn't. So our task was to fix those behaviours, and add tests to it before submitting a pull request to our local branches. Here's some insight on how it went;

P.S.: I worked with a classmate on this lab, his name is Owen Mak

1- Which URL string cases did you have trouble with in Brave vs. other browsers?

" https://www.google.ca/search?q=dog cat " and " file:///Users/humphd/repos/browser-laptop/dog cat.txt " mainly. We used both these cases to test since they both resulted in different behaviour when comparing Brave to Chrome or FireFox.

In the first case, Chrome/FireFox would redirect to a "dog cat" google search, and Brave would redirect to a "https://www.google.ca/search?q=dog cat" google search.

In the second case, Chrome/FireFox would open the file from your user path and display the contents on the page, and Brave would google search "file:///Users/humphd/repos/browser-laptop/dog cat.txt".

2- Did you notice any other interesting differences between browsers and how they handle strings in the URL bar?

The aspect that stuck out to me was that most of their tests and error handling were similar, but the order wasn't. There were a lot of things that needed to pass through checks on any browser to make sure we handle the input properly, but sometimes the order in which those checks were implemented resulted in unexpected behaviour.

3- How did you write tests for these cases?

We wrote a test for both test cases, where we did this;

+      it('is a url which contains a space in the query', function () {
+        assert.equal(urlUtil.isNotURL('https://www.google.ca/search?q=dog cat'), false)
+      })
+      it('is an absolute file path with a space in the files', function () {
+        assert.equal(urlUtil.isNotURL('/home/omak/Documents/dog cat.txt'), false)

+      })

We added an if check to add functionality so that it wouldn't fall through the checks and consider the entire URL as a google search parameter.


4- What did you do in order to get Brave to work the same as other browsers?

One of the first things we did was compare the behaviour between Brave and Chrome/FireFox like mentioned above. We wanted to see what other browsers did which ends up being what Brave doesn't do. 

5- What did you need to learn in order to complete the work?

Surprisingly, I didn't need to learn how to write tests, since I had to do that as an assignment for my Project Release 0.1. What I needed to understand was what was being tested in this scenario. Beyond that, we needed to know why the checks were failing in Brave's scenario. We did this by putting console.logs everywhere the checks were being made, and we narrowed it down from there until we found out that every space in the URL was taken out at the same time, instead of taking out the leading and trailing spaces first and encoding the spaces in the middle. That's how we found out about the bug, and we were able to fix it from there.

Comments

Popular posts from this blog

DPS909 Release 02: My First Open Source Contribution Part 1

Running Test Suites and playing with ECMA Standards