Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surrogates test #32

Merged
merged 7 commits into from
Mar 11, 2021
Merged

Surrogates test #32

merged 7 commits into from
Mar 11, 2021

Conversation

jdorweiler
Copy link
Collaborator

Screen Shot 2021-03-04 at 1 35 25 PM

@jdorweiler jdorweiler requested a review from kdzwinel March 4, 2021 20:35
Copy link
Member

@kdzwinel kdzwinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with the styling and use of all those ancient table APIs ❤️ That being said, please fix the linting, because

┏┓
┃┃╱╲ In this
┃╱╱╲╲ house
╱╱╭╮╲╲ we love
▔▏┗┛▕▔ & appreciate
╱▔▔▔▔▔▔▔▔▔▔╲
Semicolons
╱╱┏┳┓╭╮┏┳┓ ╲╲
▔▏┗┻┛┃┃┗┻┛▕▔

I also left some other comments for your enjoyment.

}
</style>
</head>
<body onload="loadSurrogates()">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this to script to make the linter happy?


const table = document.getElementById('results-table')
const row = table.insertRow(-1)
const testName = row.insertCell(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about .insertRow and .insertCell. I'm learning!

cleanUp: () => { delete window._gaq }
},
'Directly accessing a web resouce' : {
url: "chrome-extension://lfpgfgegioonagopmelghcelfgffmjnh/web_accessible_resources/analytics.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

function updateTable ({name, testData, error}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also have a global object with test results like in other tests? This way, when testing this page automatically, you will not need to scrape HTML, you'll just pull info from window.results.

@jdorweiler jdorweiler requested a review from kdzwinel March 10, 2021 00:13
s.crossOrigin = testData.crossOrigin;
}

s.src = testData.url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that in some cases (local files? cache?) event could fire before listener is set up if you provide url first. Just to be extra sure - can you move this after listeners are ready?

privacy-protections/surrogates/main.js Show resolved Hide resolved
Copy link
Member

@kdzwinel kdzwinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, I played with it though and realized that I'm missing some of the context so I left some questions.

url: 'https://google-analytics.com/analytics.js',
crossOrigin: 'anonymous',
notes: 'Test loading with crossOrigin set on element (should fail on Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1694679',
test: () => { return window.ga.answer === 42; },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we testing it this way and not the same way as _gaq?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I learned this would return true with the real ga code too. I updated it to look for an empty object from ga.create()

'google-analytics.com/analytics.js': {
url: 'https://google-analytics.com/analytics.js',
test: () => { return window.ga.answer === 42; },
cleanUp: () => { delete window.ga; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not waiting for test to load/fail, so all tests are running at once - can there be a race condition when they overlap (e.g. two tests use window.ga)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed it 👀

test: () => { return window.ga.answer === 42; },
cleanUp: () => { delete window.ga; }
},
'google-analytics, ga.js': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all other tests involve testing different configurations of analytics.js surrogate why are we also testing ga.js surrogate? Is this some kind of a special case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not special, basically the same as analytics. I got rid of it.

@kdzwinel
Copy link
Member

Thanks a lot for answering all my questions!

@kdzwinel kdzwinel merged commit 9898a33 into gh-pages Mar 11, 2021
@kdzwinel kdzwinel deleted the jd/surrogates-test branch March 11, 2021 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants