Browse Source

Add a line when a JS file is loaded

Gaël Métais 11 years ago
parent
commit
9b6b0f39f0
1 changed files with 29 additions and 0 deletions
  1. 29 0
      phantomas_custom/modules/jsFileLoadYLT/jsFileLoadYLT.js

+ 29 - 0
phantomas_custom/modules/jsFileLoadYLT/jsFileLoadYLT.js

@@ -0,0 +1,29 @@
+/**
+ * Meters the number of page errors, and provides traces as offenders for "jsErrors" metric
+ */
+'use strict';
+
+exports.version = '0.0';
+
+exports.module = function(phantomas) {
+    
+    phantomas.on('recv', function(entry, res) {
+        if (!entry.isJS) {
+            return;
+        }
+
+        // Yeah, this is weird, i'm sending the information back to the browser...
+        phantomas.evaluate(function(url) {
+            (function(phantomas) {
+
+                phantomas.pushContext({
+                    type: 'script loaded',
+                    callDetails: {
+                        arguments: [url]
+                    }
+                });
+
+            })(window.__phantomas);
+        }, entry.url);
+    });
+};