File: speechsynthesis_feature_test.html

package info (click to toggle)
webkit2gtk 2.51.90-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 484,192 kB
  • sloc: cpp: 3,930,945; javascript: 197,713; ansic: 167,619; python: 53,160; asm: 21,857; ruby: 18,114; perl: 17,149; xml: 4,631; sh: 2,462; yacc: 2,394; java: 2,032; lex: 1,358; pascal: 372; makefile: 215
file content (85 lines) | stat: -rw-r--r-- 3,746 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
    <title>SpeechSynthesis Feature Flag Test with CoreIPC Helper</title>
    <script src="coreipc.js"></script>
</head>
<body>
    <h1>SpeechSynthesis EnabledBy Feature Flag Test</h1>
    <div id="status">Loading...</div>
    
    <script>
        console.log('SpeechSynthesis feature flag test starting...');
        
        function runSpeechSynthesisTest() {
            try {
                if (typeof CoreIPC === 'undefined') {
                    alert('coreipc_framework_not_available');
                    return;
                }
                
                // Check if the SpeechSynthesisVoiceList message exists
                const messageExists = CoreIPC.messages.WebPageProxy_SpeechSynthesisVoiceList;
                console.log('SpeechSynthesisVoiceList message exists:', !!messageExists);
                
                if (!messageExists) {
                    alert('speechsynthesis_message_not_found');
                    return;
                }
                
                // Use the proper sync message pattern like the example
                const reply = IPC.sendSyncMessage(
                    'UI',
                    IPC.webPageProxyID,
                    IPC.messages.WebPageProxy_SpeechSynthesisVoiceList.name,
                    1000, // timeout in ms
                    [] // no arguments needed
                );
                
                // For EnabledBy testing, we just need to verify we got a valid reply
                // The EnabledBy mechanism will throw an error if the message is blocked
                if (reply && reply.buffer) {
                    // Check if we have a buffer with some data (skip the 16-byte header)
                    const buffer = new Uint8Array(reply.buffer);
                    console.log('Reply buffer length:', buffer.length);
                    console.log('Reply buffer (first 32 bytes):', Array.from(buffer.slice(0, 32)));
                    
                    if (buffer.length > 16) { // More than just the header
                        alert('speechsynthesis_message_sent_successfully');
                    } else {
                        alert('speechsynthesis_message_sent_empty_reply');
                    }
                } else if (reply) {
                    console.log('Got reply but no buffer:', reply);
                    alert('speechsynthesis_message_sent_no_buffer');
                } else {
                    console.log('No reply returned');
                    alert('speechsynthesis_message_sent_but_no_result');
                }
                
            } catch (error) {
                console.error('SpeechSynthesis test error:', error);
                
                // Check if this is the specific EnabledBy validation error
                if (error.message && error.message.includes('Receiver cancelled the reply due to invalid destination or deserialization error')) {
                    alert('speechsynthesis_enabledby_blocked: ' + error.message);
                } else {
                    alert('speechsynthesis_test_error: ' + error.message);
                }
            }
        }
        
        // Auto-run the test when page loads
        window.addEventListener('load', function() {
            console.log('Page loaded, starting SpeechSynthesis test...');
            setTimeout(runSpeechSynthesisTest, 100);
        });
        
        // Also run immediately in case load event already fired
        if (document.readyState === 'complete') {
            console.log('Document already complete, running SpeechSynthesis test immediately');
            setTimeout(runSpeechSynthesisTest, 100);
        }
    </script>
</body>
</html>