(action)
| 286 | * This function only tracks CHANGES during recording |
| 287 | */ |
| 288 | export function pushAction(action) { |
| 289 | // Log every action that's detected |
| 290 | console.log('📍 Action detected:', { |
| 291 | type: action.browserAction, |
| 292 | xpath: action.xpath || 'N/A', |
| 293 | url: action.url || 'N/A', |
| 294 | content: action.content || 'N/A', |
| 295 | timestamp: new Date().toISOString() |
| 296 | }); |
| 297 | |
| 298 | chrome.windows.getCurrent(function(currentWindow) { |
| 299 | action.timestamp = Date.now(); |
| 300 | var lastAction = actions[actions.length - 1]; |
| 301 | |
| 302 | // Track window dimension CHANGES from baseline |
| 303 | // Note: dimension_w and dimension_h are set during initialization |
| 304 | if (dimension_w && dimension_h && |
| 305 | (currentWindow.width !== dimension_w || currentWindow.height !== dimension_h)) { |
| 306 | console.log(`📐 Window resized: [${dimension_w}x${dimension_h}] → [${currentWindow.width}x${currentWindow.height}]`); |
| 307 | dimension_w = currentWindow.width; |
| 308 | dimension_h = currentWindow.height; |
| 309 | |
| 310 | if (compareAction(lastAction, action) === 0) { |
| 311 | console.log("Duplicated action [" + lastAction.browserAction + "] at the same element, ignore it!"); |
| 312 | } else { |
| 313 | actions.push({ |
| 314 | browserAction: ACTION_TYPES.WINDOW_RESIZE, |
| 315 | width: dimension_w, |
| 316 | height: dimension_h, |
| 317 | timestamp: Date.now() |
| 318 | }); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | if (action.browserAction === ACTION_TYPES.SCROLL) { |
| 323 | if (actions[actions.length - 1]) { |
| 324 | if (actions[actions.length - 1].browserAction === ACTION_TYPES.SCROLL) { |
| 325 | console.log("remove previous scroll in favour of the last one"); |
| 326 | actions.pop(); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | // Special handling for input actions with same xpath |
| 332 | if (action.browserAction === ACTION_TYPES.INPUT && lastAction && |
| 333 | lastAction.browserAction === ACTION_TYPES.INPUT && |
| 334 | lastAction.xpath[0] === action.xpath[0]) { |
| 335 | console.log("Update content for input action on same element"); |
| 336 | lastAction.content = action.content; |
| 337 | lastAction.timestamp = Date.now(); |
| 338 | } |
| 339 | // Normal handling for other actions |
| 340 | else if (compareAction(lastAction, action) === 0) { |
| 341 | console.log("Duplicated action [" + lastAction.browserAction + "] at the same element, ignore it!"); |
| 342 | } else { |
| 343 | action.timestamp = Date.now(); |
| 344 | actions.push(action); |
| 345 | } |
no test coverage detected