|
@@ -3,23 +3,23 @@ import {Text, View, ScrollView} from 'react-native';
|
3
|
3
|
|
4
|
4
|
import WebView from 'react-native-webview';
|
5
|
5
|
|
6
|
|
-// const HTML = `
|
7
|
|
-// <!DOCTYPE html>
|
8
|
|
-// <html>
|
9
|
|
-// <head>
|
10
|
|
-// <meta charset="utf-8">
|
11
|
|
-// <meta name="viewport" content="width=device-width, initial-scale=1">
|
12
|
|
-// <title>iframe test</title>
|
13
|
|
-// </head>
|
14
|
|
-// <body>
|
15
|
|
-// <p style="">beforeContentLoaded on the top frame <span id="before_failed" style="display: inline-block;">failed</span><span id="before_succeeded" style="display: none;">succeeded</span>!</p>
|
16
|
|
-// <p style="">afterContentLoaded on the top frame <span id="after_failed" style="display: inline-block;">failed</span><span id="after_succeeded" style="display: none;">succeeded</span>!</p>
|
17
|
|
-// <iframe src="https://birchlabs.co.uk/linguabrowse/infopages/obsol/iframe.html?v=1" name="iframe_0" style="width: 100%; height: 25px;"></iframe>
|
18
|
|
-// <iframe src="https://birchlabs.co.uk/linguabrowse/infopages/obsol/iframe2.html?v=1" name="iframe_1" style="width: 100%; height: 25px;"></iframe>
|
19
|
|
-// <iframe src="https://www.ebay.co.uk" name="iframe_2" style="width: 100%; height: 25px;"></iframe>
|
20
|
|
-// </body>
|
21
|
|
-// </html>
|
22
|
|
-// `;
|
|
6
|
+const HTML = `
|
|
7
|
+<!DOCTYPE html>
|
|
8
|
+<html>
|
|
9
|
+ <head>
|
|
10
|
+ <meta charset="utf-8">
|
|
11
|
+ <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
12
|
+ <title>iframe test</title>
|
|
13
|
+ </head>
|
|
14
|
+ <body>
|
|
15
|
+ <p style="">beforeContentLoaded on the top frame <span id="before_failed" style="display: inline-block;">failed</span><span id="before_succeeded" style="display: none;">succeeded</span>!</p>
|
|
16
|
+ <p style="">afterContentLoaded on the top frame <span id="after_failed" style="display: inline-block;">failed</span><span id="after_succeeded" style="display: none;">succeeded</span>!</p>
|
|
17
|
+ <iframe src="https://birchlabs.co.uk/linguabrowse/infopages/obsol/iframe.html?v=1" name="iframe_0" style="width: 100%; height: 25px;"></iframe>
|
|
18
|
+ <iframe src="https://birchlabs.co.uk/linguabrowse/infopages/obsol/iframe2.html?v=1" name="iframe_1" style="width: 100%; height: 25px;"></iframe>
|
|
19
|
+ <iframe src="https://www.ebay.co.uk" name="iframe_2" style="width: 100%; height: 25px;"></iframe>
|
|
20
|
+ </body>
|
|
21
|
+</html>
|
|
22
|
+`;
|
23
|
23
|
|
24
|
24
|
type Props = {};
|
25
|
25
|
type State = {
|
|
@@ -35,11 +35,12 @@ export default class Injection extends Component<Props, State> {
|
35
|
35
|
return (
|
36
|
36
|
<ScrollView>
|
37
|
37
|
<View style={{ }}>
|
38
|
|
- <View style={{ height: 300 }}>
|
|
38
|
+ <View style={{ height: 400 }}>
|
39
|
39
|
<WebView
|
40
|
40
|
/**
|
41
|
|
- * This HTML is a copy of a multi-frame JS injection test that I had lying around.
|
42
|
|
- * @see https://birchlabs.co.uk/linguabrowse/infopages/obsol/iframeTest.html
|
|
41
|
+ * This HTML is a copy of the hosted multi-frame JS injection test.
|
|
42
|
+ * I have found that Android doesn't support beforeContentLoaded for a hosted HTML webpage, yet does for a static source.
|
|
43
|
+ * The cause of this is unresolved.
|
43
|
44
|
*/
|
44
|
45
|
// source={{ html: HTML }}
|
45
|
46
|
source={{ uri: "https://birchlabs.co.uk/linguabrowse/infopages/obsol/rnw_iframe_test.html" }}
|
|
@@ -50,10 +51,12 @@ export default class Injection extends Component<Props, State> {
|
50
|
51
|
* JS injection user scripts, consistent with current behaviour. This is undesirable,
|
51
|
52
|
* so needs addressing in a follow-up PR. */
|
52
|
53
|
onMessage={() => {}}
|
|
54
|
+ injectedJavaScriptBeforeContentLoadedForMainFrameOnly={false}
|
|
55
|
+ injectedJavaScriptForMainFrameOnly={false}
|
53
|
56
|
|
54
|
57
|
/* We set this property in each frame */
|
55
|
58
|
injectedJavaScriptBeforeContentLoaded={`
|
56
|
|
- console.log("executing injectedJavaScriptBeforeContentLoaded...");
|
|
59
|
+ console.log("executing injectedJavaScriptBeforeContentLoaded... " + (new Date()).toString());
|
57
|
60
|
if(typeof window.top.injectedIframesBeforeContentLoaded === "undefined"){
|
58
|
61
|
window.top.injectedIframesBeforeContentLoaded = [];
|
59
|
62
|
}
|
|
@@ -84,12 +87,10 @@ export default class Injection extends Component<Props, State> {
|
84
|
87
|
console.log("wasn't window.top. Still going...");
|
85
|
88
|
}
|
86
|
89
|
`}
|
87
|
|
-
|
88
|
|
- injectedJavaScriptForMainFrameOnly={false}
|
89
|
90
|
|
90
|
91
|
/* We read the colourToUse property in each frame to recolour each frame */
|
91
|
92
|
injectedJavaScript={`
|
92
|
|
- console.log("executing injectedJavaScript...");
|
|
93
|
+ console.log("executing injectedJavaScript... " + (new Date()).toString());
|
93
|
94
|
if(typeof window.top.injectedIframesAfterContentLoaded === "undefined"){
|
94
|
95
|
window.top.injectedIframesAfterContentLoaded = [];
|
95
|
96
|
}
|
|
@@ -119,7 +120,7 @@ export default class Injection extends Component<Props, State> {
|
119
|
120
|
// numberOfFramesAtAfterContentLoadedEle.id = "numberOfFramesAtAfterContentLoadedEle";
|
120
|
121
|
|
121
|
122
|
var namedFramesAtBeforeContentLoadedEle = document.createElement('p');
|
122
|
|
- namedFramesAtBeforeContentLoadedEle.textContent = "Names of iframes that called beforeContentLoaded: " + JSON.stringify(window.top.injectedIframesBeforeContentLoaded);
|
|
123
|
+ namedFramesAtBeforeContentLoadedEle.textContent = "Names of iframes that called beforeContentLoaded: " + JSON.stringify(window.top.injectedIframesBeforeContentLoaded || []);
|
123
|
124
|
namedFramesAtBeforeContentLoadedEle.id = "namedFramesAtBeforeContentLoadedEle";
|
124
|
125
|
|
125
|
126
|
var namedFramesAtAfterContentLoadedEle = document.createElement('p');
|
|
@@ -147,8 +148,8 @@ export default class Injection extends Component<Props, State> {
|
147
|
148
|
<Text>✅ If the main frame becomes orange, then top-frame injection both beforeContentLoaded and afterContentLoaded is supported.</Text>
|
148
|
149
|
<Text>✅ If iframe_0, and iframe_1 become orange, then multi-frame injection beforeContentLoaded and afterContentLoaded is supported.</Text>
|
149
|
150
|
<Text>✅ If the two texts say "beforeContentLoaded on the top frame succeeded!" and "afterContentLoaded on the top frame succeeded!", then both injection times are supported at least on the main frame.</Text>
|
150
|
|
- <Text>⚠️ If either of the two iframes become coloured cyan, then for that given frame, JS injection succeeded after the content loaded, but didn't occur before the content loaded - please note that for iframes, this may not be a test failure, as it is not clear whether we would expect iframes to support an injection time of beforeContentLoaded anyway.</Text>
|
151
|
|
- <Text>⚠️ If "Names of iframes that called beforeContentLoaded: " is [], then see above.</Text>
|
|
151
|
+ <Text>❌ If either of the two iframes become coloured cyan, then for that given frame, JS injection succeeded after the content loaded, but didn't occur before the content loaded.</Text>
|
|
152
|
+ <Text>❌ If "Names of iframes that called beforeContentLoaded: " is [], then see above.</Text>
|
152
|
153
|
<Text>❌ If "Names of iframes that called afterContentLoaded: " is [], then afterContentLoaded is not supported in iframes.</Text>
|
153
|
154
|
<Text>❌ If the main frame becomes coloured cyan, then JS injection succeeded after the content loaded, but didn't occur before the content loaded.</Text>
|
154
|
155
|
<Text>❌ If the text "beforeContentLoaded on the top frame failed" remains unchanged, then JS injection has failed on the main frame before the content loaded.</Text>
|