Skip to content

Commit

Permalink
Fallback for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
niespodd committed Jun 11, 2021
1 parent 9c21cd8 commit 8dbc333
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 26 deletions.
1 change: 1 addition & 0 deletions docs/assets/index.afa733a7.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/index.e17f1f40.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/assets/index.feb49b7d.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
break-inside: avoid;
}
</style>
<script type="module" crossorigin src="assets/index.feb49b7d.js"></script>
<script type="module" crossorigin src="assets/index.afa733a7.js"></script>
<link rel="modulepreload" href="assets/vendor.0d07671f.js">
<link rel="stylesheet" href="assets/index.f44316bf.css">
</head>
Expand Down
25 changes: 15 additions & 10 deletions tester/src/testers/BasicInformation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,32 @@ const getConnectionInformation = async () => {

const BasicInformation = ({ fn, value }) => {
fn(async () => {
const devtools = devToolsOpened();
const stackLimit = await probeStackLimit();
const connection = await getConnectionInformation();
return {
let result = {
navigator: {
deviceMemory: navigator.deviceMemory,
hardwareConcurrency: navigator.hardwareConcurrency,
},
performance: {
"jsHeapSizeLimit": performance.memory.jsHeapSizeLimit,
},
stackLimit: stackLimit,
window: {
innerHeight: window.innerHeight,
innerWidth: window.innerWidth,
outerHeight: window.outerHeight,
outerWidth: window.outerWidth,
},
devtools,
connection,
};
result.devtools = devToolsOpened();
result.stackLimit = await probeStackLimit();
result.connection = await getConnectionInformation();
try {
result.performance = {
jsHeapSizeLimit: performance.memory.jsHeapSizeLimit,
};
} catch (err) {}
try {
result.performance = {
jsHeapSizeLimit: performance.memory.jsHeapSizeLimit,
};
} catch (err) {}
return result;
});

if (!value) return null;
Expand Down
30 changes: 20 additions & 10 deletions tester/src/testers/ResourceTiming.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ const TimelineVisualisation = ({ data }) => {
const ResourceTiming = ({ fn, value }) => {
fn(async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));
const performanceEntries = window.performance.getEntries();
const navigationTiming = performanceEntries.find((k) => k instanceof PerformanceNavigationTiming);
return {
navigationType: navigationTiming.type,
encodedBodySize: navigationTiming.encodedBodySize,
entriesCount: performanceEntries.length,
domainLookupTime: navigationTiming.domainLookupEnd - navigationTiming.domainLookupStart,
try {
const performanceEntries = window.performance.getEntries();
const navigationTiming = performanceEntries.find((k) => k instanceof PerformanceNavigationTiming);
return {
navigationType: navigationTiming.type,
encodedBodySize: navigationTiming.encodedBodySize,
entriesCount: performanceEntries.length,
domainLookupTime: navigationTiming.domainLookupEnd - navigationTiming.domainLookupStart,
}
} catch (err) {
return {};
}
});

Expand All @@ -87,9 +91,15 @@ const ResourceTiming = ({ fn, value }) => {

return (
<>
<Text my={4}>
You entered this page by <Code>{value.navigationType}</Code> action. Encoded body size of this page is <Code>{value.encodedBodySize}B</Code> (this can vary by encoding supported by your browser).
</Text>
{value.navigationType ? (
<Text my={4}>
You entered this page by <Code>{value.navigationType}</Code> action. Encoded body size of this page is <Code>{value.encodedBodySize}B</Code> (this can vary by encoding supported by your browser).
</Text>
) : (
<Text my={4}>
Likely <Code>PerformanceNavigationTiming</Code> is not supported by your browser.
</Text>
)}

{value.domainLookupTime < 1 && (
<Alert status="info" mb={4}>
Expand Down
18 changes: 15 additions & 3 deletions tester/src/testers/tester.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import {useDispatch, useSelector} from "react-redux";
import {Box, Heading, Text, Spinner, Alert, AlertIcon} from "@chakra-ui/react";
import {Box, Heading, Text, Spinner, Alert, AlertIcon, Code, Stack} from "@chakra-ui/react";
import {statusSet} from "../state/actions";

import mixpanel from 'mixpanel-browser';
Expand All @@ -16,6 +16,7 @@ export default (cls, config) => () => {
const usePersisted = useSelector((state) => state.persisted);
const storedValue = useSelector((state) => state.status[config.key]);
const [status, setStatus] = React.useState(true);
const [error, setError] = React.useState(undefined);
const dispatch = useDispatch();
const assocTestFn = (fn) => React.useEffect(async () => {
setStatus(TesterStatus.LOADING);
Expand All @@ -28,6 +29,8 @@ export default (cls, config) => () => {
} catch (e) {
setStatus(TesterStatus.ERROR);
mixpanel.track('failed:' + key);

setError(e.toString());
}
} else {
setStatus(TesterStatus.LOADED);
Expand All @@ -44,8 +47,17 @@ export default (cls, config) => () => {

{status === TesterStatus.ERROR && (
<Alert status="error" mt={3}>
<AlertIcon />
There was a problem running test.
<Stack>
<Box>
<AlertIcon />
There was a problem running test.
</Box>
<Box>
<Code>
{error}
</Code>
</Box>
</Stack>
</Alert>
)}

Expand Down

0 comments on commit 8dbc333

Please sign in to comment.