Browse Source

Revert "add docs"

This reverts commit bdfc19ad20fff7ef7490420f44aa60cd89f606d2.
Cheng Zhao 9 years ago
parent
commit
bb1e4c2208
3 changed files with 9 additions and 29 deletions
  1. 4 0
      atom/browser/api/lib/protocol.js
  2. 0 22
      docs/api/session.md
  3. 5 7
      spec/api-protocol-spec.js

+ 4 - 0
atom/browser/api/lib/protocol.js

@@ -19,6 +19,10 @@ var logAndThrow = function(callback, message) {
   }
 };
 
+protocol.fromPartition = function(partition) {
+  return session.fromPartition(partition).protocol;
+};
+
 protocol.registerProtocol = function(scheme, handler, callback) {
   return logAndThrow(callback, 'registerProtocol API has been replaced by the register[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.');
 };

+ 0 - 22
docs/api/session.md

@@ -523,25 +523,3 @@ The `listener` will be called with `listener(details)` when an error occurs.
   * `timestamp` Double
   * `fromCache` Boolean
   * `error` String - The error description.
-
-#### `ses.protocol`
-
-Returns an instance of [protocol](protocol.md) module for this session.
-
-```javascript
-const electron = require('electron');
-const app = electron.app;
-const session = electron.session;
-const path = require('path');
-
-app.on('ready', function() {
-    const protocol = session.fromPartition(partitionName).protocol;
-    protocol.registerFileProtocol('atom', function(request, callback) {
-      var url = request.url.substr(7);
-      callback({path: path.normalize(__dirname + '/' + url)});
-    }, function (error) {
-      if (error)
-        console.error('Failed to register protocol')
-    });
-});
-```

+ 5 - 7
spec/api-protocol-spec.js

@@ -5,7 +5,6 @@ const qs = require('querystring');
 const remote = require('electron').remote;
 const BrowserWindow = remote.require('electron').BrowserWindow;
 const protocol = remote.require('electron').protocol;
-const session = remote.require('electron').session;
 
 describe('protocol module', function() {
   var protocolName = 'sp';
@@ -819,7 +818,7 @@ describe('protocol module', function() {
 
   describe('protocol.fromPartition', function() {
     var partitionName = 'temp';
-    var tempProtocol = session.fromPartition(partitionName).protocol;
+    var tempProtocol = protocol.fromPartition(partitionName);
     var w = null;
 
     beforeEach(function() {
@@ -853,18 +852,17 @@ describe('protocol module', function() {
         if (error) {
           return done(error);
         }
-
         protocol.isProtocolHandled(protocolName, function(result) {
           assert.equal(result, false);
         });
         tempProtocol.isProtocolHandled(protocolName, function(result) {
           assert.equal(result, true);
-          w.webContents.on('did-finish-load', function() {
-            done();
-          });
-          w.loadURL(protocolName + "://fake-host");
         });
       });
+      w.webContents.on('did-finish-load', function() {
+        done();
+      });
+      w.loadURL(protocolName + "://fake-host");
     });
   });
 });