Skip to content

Commit

Permalink
testing logs to debug mobile safari on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Apr 22, 2016
1 parent dcb3629 commit 9777480
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
24 changes: 22 additions & 2 deletions src/core/overlay/position/viewport-ruler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ export function main() {

// Create a very large element that will make the page scrollable.
let veryLargeElement: HTMLElement = document.createElement('div');
veryLargeElement.style.width = '4000px';
veryLargeElement.style.height = '4000px';
veryLargeElement.style.width = '6000px';
veryLargeElement.style.height = '6000px';

beforeEach(() => {
ruler = new ViewportRuler();
scrollTo(0, 0);

document.body.style.width = '1024px';
document.body.style.height = '768px';
document.body.style.overflow = 'scroll';
});

it('should get the viewport bounds when the page is not scrolled', () => {
Expand All @@ -42,6 +47,21 @@ export function main() {
scrollTo(2000, 1500);

let bounds = ruler.getViewportRect();

console.log('window');
console.log('window.innerWidth', window.innerWidth);
console.log('window.innherHeight', window.innerHeight);

console.log('body');
console.log('scrollHeight:', document.body.scrollHeight);
console.log('scrollTop:', document.body.scrollTop);
console.log('rect.top:', document.body.getBoundingClientRect().top);

console.log('documentElement');
console.log('scrollHeight:', document.documentElement.scrollHeight);
console.log('scrollTop:', document.documentElement.scrollTop);
console.log('rect.top:', document.documentElement.getBoundingClientRect().top);

expect(bounds.top).toBe(2000);
expect(bounds.left).toBe(1500);
expect(bounds.bottom).toBe(2000 + window.innerHeight);
Expand Down
8 changes: 6 additions & 2 deletions src/core/overlay/position/viewport-ruler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export class ViewportRuler {
// `scrollTop` and `scrollLeft` is inconsistent. However, using the bounding rect of
// `document.documentElement` works consistently, where the `top` and `left` values will
// equal negative the scroll position.
const top = documentRect.top < 0 ? -documentRect.top : document.documentElement.scrollTop;
const left = documentRect.left < 0 ? -documentRect.left : document.documentElement.scrollLeft;
const top = documentRect.top < 0 && document.body.scrollTop == 0 ?
-documentRect.top :
document.body.scrollTop;
const left = documentRect.left < 0 && document.body.scrollLeft == 0 ?
-documentRect.left :
document.body.scrollLeft;

return {top, left};
}
Expand Down
15 changes: 9 additions & 6 deletions test/browser-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ const configuration: { [name: string]: ConfigurationInfo } = {
'Safari7': { unitTest: {target: null, required: false}, e2e: {target: null, required: true}},
'Safari8': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
'Safari9': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
'iOS7': { unitTest: {target: 'BS', required: true}, e2e: {target: null, required: true}},
'iOS8': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
'iOS7': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
'iOS8': { unitTest: {target: 'BS', required: true}, e2e: {target: null, required: true}},
// TODO(mlaval): iOS9 deactivated as not reliable, reactivate after
// https://github.com/angular/angular/issues/5408
'iOS9': { unitTest: {target: null, required: false}, e2e: {target: null, required: true}},
'iOS9': { unitTest: {target: 'BS', required: true}, e2e: {target: null, required: true}},
'WindowsPhone': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}}
};

Expand Down Expand Up @@ -217,19 +217,22 @@ export const customLaunchers: { [name: string]: BrowserLauncherInfo } = {
base: 'BrowserStack',
device: 'iPhone 5S',
os: 'ios',
os_version: '7.0'
os_version: '7.0',
resolution: '1024x768'
},
'BS_IOS8': {
base: 'BrowserStack',
device: 'iPhone 6',
os: 'ios',
os_version: '8.3'
os_version: '8.3',
resolution: '1024x768'
},
'BS_IOS9': {
base: 'BrowserStack',
device: 'iPhone 6S',
os: 'ios',
os_version: '9.0'
os_version: '9.0',
resolution: '1024x768'
},
'BS_IE9': {
base: 'BrowserStack',
Expand Down

0 comments on commit 9777480

Please sign in to comment.