- Move test_verify.py and test-content-script.js to tests/ - Remove unused test_start_extension.sh - Rename Dockerfile stages: test → code_quality, verify → integration_test - Simplify test to single assertion: 17*2+3=37 - Add red TTY output for failures - Fix runtime stage to properly copy built artifacts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
2.8 KiB
JavaScript
69 lines
2.8 KiB
JavaScript
// Test content script - only for automated testing
|
|
// This script proves bidirectional communication between content script and background
|
|
|
|
// Set initial DOM marker to prove content script is injected
|
|
|
|
(function() {
|
|
function setMarker() {
|
|
if (document.body) {
|
|
document.body.setAttribute('data-rentgen-injected', 'true');
|
|
} else {
|
|
// Wait for DOM ready
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.body.setAttribute('data-rentgen-injected', 'true');
|
|
});
|
|
}
|
|
}
|
|
}
|
|
setMarker();
|
|
})();
|
|
|
|
// Listen for test request from Marionette test script
|
|
document.addEventListener('rentgen_test_request', async (event) => {
|
|
try {
|
|
// Mark that we received the event
|
|
document.body.setAttribute('data-rentgen-event-received', 'true');
|
|
|
|
// Extract test data from event
|
|
const testData = event.detail || {};
|
|
const inputValue = testData.value || 42;
|
|
const timestamp = testData.timestamp || Date.now();
|
|
|
|
// Send message to background script and wait for response
|
|
// This proves background script is running and responsive
|
|
const response = await browser.runtime.sendMessage({
|
|
type: 'RENTGEN_TEST_VERIFICATION',
|
|
inputValue: inputValue,
|
|
timestamp: timestamp,
|
|
url: window.location.href,
|
|
title: document.title
|
|
});
|
|
|
|
// Store the response from background in DOM
|
|
// This provides undeniable proof of bidirectional communication
|
|
if (response && response.success) {
|
|
document.body.setAttribute('data-rentgen-verified', 'true');
|
|
document.body.setAttribute('data-rentgen-computed', String(response.computed));
|
|
document.body.setAttribute('data-rentgen-formula', response.formula);
|
|
document.body.setAttribute('data-rentgen-background-timestamp', String(response.backgroundTimestamp));
|
|
|
|
// Also dispatch a custom event with the results
|
|
document.dispatchEvent(new CustomEvent('rentgen_test_complete', {
|
|
detail: {
|
|
success: true,
|
|
computed: response.computed,
|
|
formula: response.formula,
|
|
backgroundTimestamp: response.backgroundTimestamp
|
|
}
|
|
}));
|
|
} else {
|
|
document.body.setAttribute('data-rentgen-verified', 'false');
|
|
document.body.setAttribute('data-rentgen-error', 'No response from background');
|
|
}
|
|
} catch (error) {
|
|
// Store error in DOM for debugging
|
|
document.body.setAttribute('data-rentgen-verified', 'false');
|
|
document.body.setAttribute('data-rentgen-error', String(error));
|
|
}
|
|
}); |